diff --git a/bindings/authenticatedConnection.go b/bindings/authenticatedConnection.go index 33aac039b7bea7ff91e5f021103e22442bc615ba..3cd2fcd009b7d47160e9002b60b4844ff1d43ade 100644 --- a/bindings/authenticatedConnection.go +++ b/bindings/authenticatedConnection.go @@ -34,7 +34,6 @@ func (_ *AuthenticatedConnection) IsAuthenticated() bool { // ConnectWithAuthentication is called by the client (i.e., the one establishing // connection with the server). Once a connect.Connection has been established // with the server, it then authenticates their identity to the server. -// accepts a marshalled ReceptionIdentity and contact.Contact object func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact, e2eParamsJSON []byte) (*AuthenticatedConnection, error) { if len(e2eParamsJSON) == 0 { diff --git a/bindings/backup.go b/bindings/backup.go index 2c5c24560184fe5d1f121e05b8df5de98ce1fc23..b7756fccb06b3df2b25f6ab5da3aa06f7d1e6313 100644 --- a/bindings/backup.go +++ b/bindings/backup.go @@ -55,7 +55,7 @@ type UpdateBackupFunc interface { // backup. Users of this function should delete the storage directory on error. // Users of this function should call LoadCmix as normal once this call succeeds. // -// Params +// Parameters: // - ndfJSON - JSON of the NDF. // - storageDir - directory for the storage files. // - sessionPassword - password to decrypt the data in the storageDir. @@ -92,10 +92,11 @@ func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string, // InitializeBackup creates a bindings-layer Backup object. // -// Params +// Parameters: // - e2eID - ID of the E2e object in the e2e tracker. // - udID - ID of the UserDiscovery object in the ud tracker. -// - backupPassPhrase - backup passphrase provided by the user. Used to decrypt backup. +// - backupPassPhrase - backup passphrase provided by the user. Used to decrypt +// backup. // - cb - the callback to be called when a backup is triggered. func InitializeBackup(e2eID, udID int, backupPassPhrase string, cb UpdateBackupFunc) (*Backup, error) { @@ -129,7 +130,7 @@ func InitializeBackup(e2eID, udID int, backupPassPhrase string, // To start the backup for the first time or to use a new password, use // InitializeBackup. // -// Params +// Parameters: // - e2eID - ID of the E2e object in the e2e tracker. // - udID - ID of the UserDiscovery object in the ud tracker. // - cb - the callback to be called when a backup is triggered. diff --git a/bindings/broadcast.go b/bindings/broadcast.go index 62cce68bc271509b19f92aa4c44dac6f2c9ff7d9..6cea173b9000ede941c7c640727912c21f6e8cb0 100644 --- a/bindings/broadcast.go +++ b/bindings/broadcast.go @@ -19,18 +19,21 @@ import ( "gitlab.com/xx_network/primitives/id/ephemeral" ) -// Channel is a bindings-level struct encapsulating the broadcast.Channel client object. +// Channel is a bindings-level struct encapsulating the broadcast.Channel client +// object. type Channel struct { ch broadcast.Channel } -// ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. +// ChannelDef is the bindings representation of an elixxir/crypto +// broadcast.Channel object. // // Example JSON: -// {"Name": "My broadcast channel", -// "Description":"A broadcast channel for me to test things", -// "Salt":"gpUqW7N22sffMXsvPLE7BA==", -// "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" +// { +// "Name": "My broadcast channel", +// "Description": "A broadcast channel for me to test things", +// "Salt": "gpUqW7N22sffMXsvPLE7BA==", +// "PubKey": "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" // } type ChannelDef struct { Name string @@ -51,7 +54,8 @@ type BroadcastMessage struct { Payload []byte } -// BroadcastReport is the bindings representation of the info on how a broadcast message was sent +// BroadcastReport is the bindings representation of the info on how a broadcast +// message was sent // // Example JSON: // {"RoundID":42, @@ -72,7 +76,8 @@ type BroadcastListener interface { Callback([]byte, error) } -// NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages +// NewBroadcastChannel creates a bindings-layer broadcast channel and starts +// listening for new messages. // // Parameters: // - cmixId - internal ID of cmix @@ -112,8 +117,8 @@ func NewBroadcastChannel(cmixId int, channelDefinition []byte) (*Channel, error) return &Channel{ch: ch}, nil } -// Listen registers a BroadcastListener for a given method. -// This allows users to handle incoming broadcast messages. +// Listen registers a BroadcastListener for a given method. This allows users to +// handle incoming broadcast messages. // // Parameters: // - l - BroadcastListener object @@ -139,7 +144,8 @@ func (c *Channel) Listen(l BroadcastListener, method int) error { // // Returns: // - []byte - the JSON marshalled bytes of the BroadcastReport object, which -// can be passed into WaitForRoundResult to see if the broadcast succeeded. +// can be passed into Cmix.WaitForRoundResult to see if the broadcast +// succeeded. func (c *Channel) Broadcast(payload []byte) ([]byte, error) { rid, eid, err := c.ch.Broadcast(payload, cmix.GetDefaultCMIXParams()) if err != nil { @@ -172,17 +178,20 @@ func (c *Channel) BroadcastAsymmetric(payload, pk []byte) ([]byte, error) { }) } -// MaxPayloadSize returns the maximum possible payload size which can be broadcast. +// MaxPayloadSize returns the maximum possible payload size which can be +// broadcast. func (c *Channel) MaxPayloadSize() int { return c.ch.MaxPayloadSize() } -// MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. +// MaxAsymmetricPayloadSize returns the maximum possible payload size which can +// be broadcast. func (c *Channel) MaxAsymmetricPayloadSize() int { return c.ch.MaxAsymmetricPayloadSize() } -// Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. +// Get returns the result of calling json.Marshal on a ChannelDef based on the +// underlying crypto broadcast.Channel. func (c *Channel) Get() ([]byte, error) { def := c.ch.Get() return json.Marshal(&ChannelDef{ diff --git a/bindings/connect.go b/bindings/connect.go index c097d0cb3a23c9366ff6057a690c2b92845bc2aa..912ee6ffa9744e12a5b44ae626a198cb6e9bb36e 100644 --- a/bindings/connect.go +++ b/bindings/connect.go @@ -48,7 +48,7 @@ func (c *Connection) GetId() int { // Parameters: // - e2eId - ID of the E2E object in the e2e tracker // - recipientContact - marshalled contact.Contact object -// - myIdentity - marshalled ReceptionIdentity object +// - e2eParamsJSON - JSON marshalled byte of xxdk.E2EParams object func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) ( *Connection, error) { if len(e2eParamsJSON) == 0 { @@ -83,7 +83,7 @@ func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) ( // // Returns: // - []byte - the JSON marshalled bytes of the E2ESendReport object, which can -// be passed into WaitForRoundResult to see if the send succeeded. +// be passed into Cmix.WaitForRoundResult to see if the send succeeded. func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { rounds, mid, ts, err := c.connection.SendE2E(catalog.MessageType(mt), payload, c.params.Base) diff --git a/bindings/delivery.go b/bindings/delivery.go index 7d549ec7d397da9654ff5be8fccdd7122a6c3c2f..39df199c799b395cae42e0743debca49375a46c0 100644 --- a/bindings/delivery.go +++ b/bindings/delivery.go @@ -70,19 +70,21 @@ type MessageDeliveryCallback interface { EventCallback(delivered, timedOut bool, roundResults []byte) } -// WaitForRoundResult allows the caller to get notified if the rounds a -// message was sent in successfully completed. Under the hood, this uses an API -// that uses the internal round data, network historical round lookup, and -// waiting on network events to determine what has (or will) occur. -// -// The callbacks will return at timeoutMS if no state update occurs. +// WaitForRoundResult allows the caller to get notified if the rounds a message +// was sent in successfully completed. Under the hood, this uses an API that +// uses the internal round data, network historical round lookup, and waiting on +// network events to determine what has (or will) occur. // // This function takes the marshaled send report to ensure a memory leak does // not occur as a result of both sides of the bindings holding a reference to // the same pointer. // -// roundList is a JSON marshalled RoundsList or any JSON marshalled send report -// that inherits a RoundsList object. +// Parameters: +// - roundList - JSON marshalled bytes of RoundsList or JSON of any send report +// that inherits a [bindings.RoundsList] object +// - mdc - callback that adheres to the MessageDeliveryCallback interface +// - timeoutMS - timeout when the callback will return if no state update +// occurs, in milliseconds func (c *Cmix) WaitForRoundResult( roundList []byte, mdc MessageDeliveryCallback, timeoutMS int) error { jww.INFO.Printf("WaitForRoundResult(%s, _, %d)", roundList, timeoutMS) diff --git a/bindings/dummy.go b/bindings/dummy.go index b193a1cf07edcec7f574c0fa60b40ae5d6531fe2..6d6ee3c391c3edfb6812347f702d16bbc65dc443 100644 --- a/bindings/dummy.go +++ b/bindings/dummy.go @@ -20,21 +20,21 @@ type DummyTraffic struct { } // NewDummyTrafficManager creates a DummyTraffic manager and initialises the -// dummy traffic sending thread. Note that the manager does not start sending dummy -// traffic until `True` is passed into DummyTraffic.SetStatus. The time duration -// between each sending operation and the amount of messages sent each interval -// are randomly generated values with bounds defined by the -// given parameters below. +// dummy traffic sending thread. Note that the manager does not start sending +// dummy traffic until true is passed into DummyTraffic.SetStatus. The time +// duration between each sending operation and the amount of messages sent each +// interval are randomly generated values with bounds defined by the given +// parameters below. // -// Params: +// Parameters: // - cmixId - a Cmix object ID in the tracker. // - maxNumMessages - the upper bound of the random number of messages sent // each sending cycle. -// - avgSendDeltaMS - the average duration, in milliseconds, to wait -// between sends. -// - randomRangeMS - the upper bound of the interval between sending cycles, -// in milliseconds. Sends occur every avgSendDeltaMS +/- a random duration -// with an upper bound of randomRangeMS. +// - avgSendDeltaMS - the average duration, in milliseconds, to wait between +// sends. +// - randomRangeMS - the upper bound of the interval between sending cycles, in +// milliseconds. Sends occur every avgSendDeltaMS +/- a random duration with +// an upper bound of randomRangeMS. func NewDummyTrafficManager(cmixId, maxNumMessages, avgSendDeltaMS, randomRangeMS int) (*DummyTraffic, error) { @@ -53,33 +53,34 @@ func NewDummyTrafficManager(cmixId, maxNumMessages, avgSendDeltaMS, return &DummyTraffic{m}, net.api.AddService(m.StartDummyTraffic) } -// SetStatus sets the state of the DummyTraffic manager's send thread by passing in -// a boolean parameter. There may be a small delay in between this call -// and the status of the sending thread to change accordingly. For example, -// passing False into this call while the sending thread is currently sending messages -// will not cancel nor halt the sending operation, but will pause the thread once that -// operation has completed. +// SetStatus sets the state of the DummyTraffic manager's send thread by passing +// in a boolean parameter. There may be a small delay in between this call and +// the status of the sending thread to change accordingly. For example, passing +// false into this call while the sending thread is currently sending messages +// will not cancel nor halt the sending operation, but will pause the thread +// once that operation has completed. +// +// Parameters: +// - status - Input should be true if you want to send dummy messages and false +// if you want to pause dummy messages. // -// Params: -// - boolean - Input should be true if you want to send dummy messages. -// Input should be false if you want to pause dummy messages. // Returns: -// - error - if the DummyTraffic.SetStatus is called too frequently, causing the -// internal status channel to fill. +// - error - if the DummyTraffic.SetStatus is called too frequently, causing +// the internal status channel to fill. func (dt *DummyTraffic) SetStatus(status bool) error { return dt.m.SetStatus(status) } -// GetStatus returns the current state of the DummyTraffic manager's sending thread. -// Note that this function does not return the status set by the most recent call to -// SetStatus. Instead, this call returns the current status of the sending thread. -// This is due to the small delay that may occur between calling SetStatus and the -// sending thread taking into effect that status change. +// GetStatus returns the current state of the DummyTraffic manager's sending +// thread. Note that this function does not return the status set by the most +// recent call to SetStatus. Instead, this call returns the current status of +// the sending thread. This is due to the small delay that may occur between +// calling SetStatus and the sending thread taking into effect that status +// change. // // Returns: -// - boolean - Returns true if sending thread is sending dummy messages. -// Returns false if sending thread is paused/stopped and is -// not sending dummy messages. +// - bool - Returns true if sending thread is sending dummy messages and false +// if sending thread is paused/stopped and is not sending dummy messages. func (dt *DummyTraffic) GetStatus() bool { return dt.m.GetStatus() } diff --git a/bindings/e2eAuth.go b/bindings/e2eAuth.go index 801a2829ec1feb9584a90bd80015b9d5f35baefe..cee5f04f4d0e1fafcaecc8c65ff5cdb56e3c9209 100644 --- a/bindings/e2eAuth.go +++ b/bindings/e2eAuth.go @@ -171,8 +171,7 @@ func (e *E2e) DeleteSentRequests() error { return e.api.GetAuth().DeleteSentRequests() } -// DeleteReceiveRequests clears all received requests from auth -// storage. +// DeleteReceiveRequests clears all received requests from auth storage. func (e *E2e) DeleteReceiveRequests() error { return e.api.GetAuth().DeleteReceiveRequests() } diff --git a/bindings/e2eHandler.go b/bindings/e2eHandler.go index 83ca76d62341b62162fa97d19be63b5537c517d2..b71d6646d85eec5cea9a4450979d75003e20b9d2 100644 --- a/bindings/e2eHandler.go +++ b/bindings/e2eHandler.go @@ -24,9 +24,11 @@ import ( // SendE2E. // // Example E2ESendReport: -// {"Rounds":[1,5,9], +// { +// "Rounds":[1,5,9], // "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", -// "Timestamp":1653582683183384000} +// "Timestamp":1653582683183384000 +// } type E2ESendReport struct { RoundsList MessageID []byte @@ -117,7 +119,7 @@ func (e *E2e) RemoveService(tag string) error { // // Returns: // - []byte - the JSON marshalled bytes of the E2ESendReport object, which can -// be passed into WaitForRoundResult to see if the send succeeded. +// be passed into Cmix.WaitForRoundResult to see if the send succeeded. func (e *E2e) SendE2E(messageType int, recipientId, payload, e2eParams []byte) ([]byte, error) { // Note that specifically these are the Base params from xxdk.E2EParams @@ -166,11 +168,9 @@ func (e *E2e) AddService(tag string, processor Processor) error { // - messageType - message type from the sender you want to listen for. // - newListener: A provider for a callback to hear a message. // Do not pass nil to this. -func (e *E2e) RegisterListener(senderID []byte, - messageType int, - newListener Listener) error { - jww.INFO.Printf("RegisterListener(%v, %d)", senderID, - messageType) +func (e *E2e) RegisterListener( + senderID []byte, messageType int, newListener Listener) error { + jww.INFO.Printf("RegisterListener(%v, %d)", senderID, messageType) // Convert senderID to id.Id object var uid *id.ID diff --git a/bindings/errors.go b/bindings/errors.go index 32c945c80c219626623b39ce12e3f299c1f73cef..c5f4edce5a03fd31ce40ca5c15c3e689fe16e174 100644 --- a/bindings/errors.go +++ b/bindings/errors.go @@ -46,14 +46,14 @@ const ( UnrecognizedMessage = UnrecognizedCode + "Unrecognized error from XX backend, please report" ) -// CreateUserFriendlyErrorMessage will convert the passed in error string -// to an error string that is user-friendly if a substring match is -// found to a common error. Common errors is a map which can be updated -// using UpdateCommonErrors. If the error is not common, some simple parsing -// is done on the error message to make it more user-accessible, removing -// backend specific jargon. +// CreateUserFriendlyErrorMessage will convert the passed in error string to an +// error string that is user-friendly if a substring match is found to a +// common error. Common errors is a map that can be updated using +// UpdateCommonErrors. If the error is not common, some simple parsing is done +// on the error message to make it more user-accessible, removing backend +// specific jargon. // -// Parameters +// Parameters: // - errStr - an error returned from the backend. // // Returns @@ -97,16 +97,18 @@ func CreateUserFriendlyErrorMessage(errStr string) string { return fmt.Sprintf("%s: %v", UnrecognizedCode, errStr) } -// UpdateCommonErrors updates the internal error mapping DB. This internal database -// maps errors returned from the backend to user-friendly error messages. +// UpdateCommonErrors updates the internal error mapping database. This internal +// database maps errors returned from the backend to user-friendly error +// messages. // -// Parameters +// Parameters: // - jsonFile - contents of a JSON file whose format conforms to the example below. +// // Example Input: -// { -// "Failed to Unmarshal Conversation": "Could not retrieve conversation", -// "Failed to unmarshal SentRequestMap": "Failed to pull up friend requests", -// "cannot create username when network is not health": "Cannot create username, unable to connect to network", +// { +// "Failed to Unmarshal Conversation": "Could not retrieve conversation", +// "Failed to unmarshal SentRequestMap": "Failed to pull up friend requests", +// "cannot create username when network is not health": "Cannot create username, unable to connect to network", // } func UpdateCommonErrors(jsonFile string) error { errorMux.Lock() diff --git a/bindings/fileTransfer.go b/bindings/fileTransfer.go index b0182ed6e2cb9c018a54ee716946e60cbb74f328..79a7d6bc7cbda08f0cc9b85341a82692bb834362 100644 --- a/bindings/fileTransfer.go +++ b/bindings/fileTransfer.go @@ -179,7 +179,6 @@ func InitFileTransfer(e2eID int, receiveFileCallback ReceiveFileCallback, // Parameters: // - payload - JSON marshalled FileSend // - recipientID - marshalled recipient id.ID -// - paramsJSON - JSON marshalled e2e.Params // - retry - number of retries allowed // - callback - callback that reports file sending progress // - period - duration to wait between progress callbacks triggering diff --git a/bindings/follow.go b/bindings/follow.go index 482bbd9cd83ab254ee2677a494d8e720df67c88d..6267a34125388a681827437d7a1e1cea1aa1c8dd 100644 --- a/bindings/follow.go +++ b/bindings/follow.go @@ -27,28 +27,28 @@ import ( // // Threads Started: // - Network Follower (/network/follow.go) -// tracks the network events and hands them off to workers for handling. +// tracks the network events and hands them off to workers for handling. // - Historical Round Retrieval (/network/rounds/historical.go) -// retrieves data about rounds that are too old to be stored by the client. +// retrieves data about rounds that are too old to be stored by the client. // - Message Retrieval Worker Group (/network/rounds/retrieve.go) -// requests all messages in a given round from the gateway of the last -// nodes. +// requests all messages in a given round from the gateway of the last +// nodes. // - Message Handling Worker Group (/network/message/handle.go) -// decrypts and partitions messages when signals via the Switchboard. +// decrypts and partitions messages when signals via the Switchboard. // - Health Tracker (/network/health), -// via the network instance, tracks the state of the network. +// via the network instance, tracks the state of the network. // - Garbled Messages (/network/message/garbled.go) -// can be signaled to check all recent messages that could be decoded. It -// uses a message store on disk for persistence. +// can be signaled to check all recent messages that could be decoded. It +// uses a message store on disk for persistence. // - Critical Messages (/network/message/critical.go) -// ensures all protocol layer mandatory messages are sent. It uses a -// message store on disk for persistence. +// ensures all protocol layer mandatory messages are sent. It uses a message +// store on disk for persistence. // - KeyExchange Trigger (/keyExchange/trigger.go) -// responds to sent rekeys and executes them. +// responds to sent rekeys and executes them. // - KeyExchange Confirm (/keyExchange/confirm.go) -// responds to confirmations of successful rekey operations. +// responds to confirmations of successful rekey operations. // - Auth Callback (/auth/callback.go) -// handles both auth confirm and requests. +// handles both auth confirm and requests. func (c *Cmix) StartNetworkFollower(timeoutMS int) error { timeout := time.Duration(timeoutMS) * time.Millisecond return c.api.StartNetworkFollower(timeout) @@ -58,7 +58,7 @@ func (c *Cmix) StartNetworkFollower(timeoutMS int) error { // an error if the follower is in the wrong state to stop or if it fails to stop // it. // -// if the network follower is running and this fails, the Cmix object will +// If the network follower is running and this fails, the Cmix object will // most likely be in an unrecoverable state and need to be trashed. func (c *Cmix) StopNetworkFollower() error { if err := c.api.StopNetworkFollower(); err != nil { @@ -84,11 +84,9 @@ func (c *Cmix) WaitForNetwork(timeoutMS int) bool { // NetworkFollowerStatus gets the state of the network follower. It returns a // status with the following values: -// -// Status: -// - Stopped - 0 -// - Running - 2000 -// - Stopping - 3000 +// Stopped - 0 +// Running - 2000 +// Stopping - 3000 func (c *Cmix) NetworkFollowerStatus() int { return int(c.api.NetworkFollowerStatus()) } @@ -103,10 +101,11 @@ type NodeRegistrationReport struct { // GetNodeRegistrationStatus returns the current state of node registration. // // Returns: -// - []bye - A marshalled NodeRegistrationReport containing the number of -// nodes the user is registered with and the number of nodes present in the NDF. -// - An error if it cannot get the node registration status. The most likely cause -// is that the network is unhealthy. +// - []byte - A marshalled NodeRegistrationReport containing the number of +// nodes the user is registered with and the number of nodes present in the +// NDF. +// - An error if it cannot get the node registration status. The most likely +// cause is that the network is unhealthy. func (c *Cmix) GetNodeRegistrationStatus() ([]byte, error) { numNodesRegistered, numNodes, err := c.api.GetNodeRegistrationStatus() if err != nil { diff --git a/bindings/group.go b/bindings/group.go index 00951c269e43843fd3bd05609f1bddc9562cb844..709a969091b8bbddd5a2d242e8ddab0e51312e9a 100644 --- a/bindings/group.go +++ b/bindings/group.go @@ -22,7 +22,7 @@ import ( ) //////////////////////////////////////////////////////////////////////////////// -// Group Singleton Tracker // +// Group Singleton Tracker // //////////////////////////////////////////////////////////////////////////////// // groupTrackerSingleton is used to track Group objects so that they can be @@ -129,16 +129,16 @@ func NewGroupChat(e2eID int, // IDs of members the user wants to add to the group. // - message - the initial message sent to all members in the group. This is an // optional parameter and may be nil. -// - tag - the name of the group decided by the creator. This is an optional +// - name - the name of the group decided by the creator. This is an optional // parameter and may be nil. If nil the group will be assigned the default // name. // // Returns: // - []byte - the JSON marshalled bytes of the GroupReport object, which can be -// passed into WaitForRoundResult to see if the group request message send -// succeeded. -func (g *GroupChat) MakeGroup(membershipBytes []byte, message, name []byte) ( - []byte, error) { +// passed into Cmix.WaitForRoundResult to see if the group request message +// send succeeded. +func (g *GroupChat) MakeGroup( + membershipBytes, message, name []byte) ([]byte, error) { // Unmarshal membership list into a list of []*id.Id var members []*id.ID @@ -246,17 +246,16 @@ func (g *GroupChat) LeaveGroup(groupId []byte) error { // Send is the bindings-level function for sending to a group. // // Parameters: -// - groupId - the byte data representing a group ID. -// This can be pulled from a marshalled GroupReport. +// - groupId - the byte data representing a group ID. This can be pulled from +// marshalled GroupReport. // - message - the message that the user wishes to send to the group. // - tag - the tag associated with the message. This tag may be empty. // // Returns: // - []byte - the JSON marshalled bytes of the GroupSendReport object, which -// can be passed into WaitForRoundResult to see if the group message send -// succeeded. -func (g *GroupChat) Send(groupId, - message []byte, tag string) ([]byte, error) { +// can be passed into Cmix.WaitForRoundResult to see if the group message +// send succeeded. +func (g *GroupChat) Send(groupId, message []byte, tag string) ([]byte, error) { groupID, err := id.Unmarshal(groupId) if err != nil { return nil, errors.Errorf("Failed to unmarshal group ID: %+v", err) @@ -291,7 +290,7 @@ func (g *GroupChat) GetGroups() ([]byte, error) { // // Parameters: // - groupId - The byte data representing a group ID (a byte marshalled id.ID). -// This can be pulled from a marshalled GroupReport. +// This can be pulled from a marshalled GroupReport. // Returns: // - Group - The bindings-layer representation of a group. func (g *GroupChat) GetGroup(groupId []byte) (*Group, error) { @@ -317,7 +316,7 @@ func (g *GroupChat) NumGroups() int { } //////////////////////////////////////////////////////////////////////////////// -// Group Structure +// Group Structure // //////////////////////////////////////////////////////////////////////////////// // Group structure contains the identifying and membership information of a @@ -332,12 +331,13 @@ func (g *Group) GetName() []byte { return g.g.Name } -// GetID return the 33-byte unique group ID. This represents the id.ID object +// GetID return the 33-byte unique group ID. This represents the id.ID object. func (g *Group) GetID() []byte { return g.g.ID.Bytes() } -// GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. +// GetTrackedID returns the tracked ID of the Group object. This is used by the +// backend tracker. func (g *Group) GetTrackedID() int { return g.id } @@ -375,9 +375,9 @@ func (g *Group) Serialize() []byte { return g.g.Serialize() } -////////////////////////////////////////////////////////////////////////////////// -// Callbacks -////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// Callbacks // +//////////////////////////////////////////////////////////////////////////////// // GroupRequest is a bindings-layer interface that handles a group reception. // diff --git a/bindings/logging.go b/bindings/logging.go index 6783d4b546f293862863110a85b16791dbf88baa..a4b1df6ae671f808ce5594f5ab1ae0e204d81cfc 100644 --- a/bindings/logging.go +++ b/bindings/logging.go @@ -10,7 +10,6 @@ package bindings import ( - "fmt" "log" "github.com/pkg/errors" @@ -34,7 +33,7 @@ import ( // The default log level without updates is INFO. func LogLevel(level int) error { if level < 0 || level > 6 { - return errors.New(fmt.Sprintf("log level is not valid: log level: %d", level)) + return errors.Errorf("log level is not valid: log level: %d", level) } threshold := jww.Threshold(level) diff --git a/bindings/params.go b/bindings/params.go index 2b0cdd18c82d16c2a7a3f0b5570532d26bf87b23..151811be715db3ce2d612173b6d2b45bcfd84417 100644 --- a/bindings/params.go +++ b/bindings/params.go @@ -66,8 +66,8 @@ func GetDefaultSingleUseParams() []byte { } // GetDefaultE2eFileTransferParams returns a JSON serialized object with all the -// e2e file transfer parameters and their default values. Call this function and modify -// the JSON to change single use settings. +// E2E file transfer parameters and their default values. Call this function and +// modify the JSON to change single use settings. func GetDefaultE2eFileTransferParams() []byte { defaultParams := e2eFileTransfer.DefaultParams() data, err := defaultParams.MarshalJSON() diff --git a/bindings/restlike.go b/bindings/restlike.go index e3c87e1d8279f60833ae91a8e49f32597fcf8352..2fe52c8aa5df83a31f5f49be27e16c2d384705f0 100644 --- a/bindings/restlike.go +++ b/bindings/restlike.go @@ -107,7 +107,7 @@ func RestlikeRequest( // // Returns: // - []byte - JSON marshalled RestlikeMessage -func RestlikeRequestAuth(cmixId int, authConnectionID int, request, +func RestlikeRequestAuth(cmixId, authConnectionID int, request, e2eParamsJSON []byte) ([]byte, error) { if len(e2eParamsJSON) == 0 { jww.WARN.Printf("restlike params unspecified, using defaults") diff --git a/bindings/single.go b/bindings/single.go index ffea48c71701f167e4bab24b879f18b539df1042..ca0e855cb2bdd53baa1da576ec198f2db5587976 100644 --- a/bindings/single.go +++ b/bindings/single.go @@ -68,8 +68,8 @@ func TransmitSingleUse(e2eID int, recipient []byte, tag string, payload, return json.Marshal(sr) } -// Listen starts a single-use listener on a given tag using the passed in e2e object -// and SingleUseCallback func. +// Listen starts a single-use listener on a given tag using the passed in E2e +// object and SingleUseCallback func. // // Parameters: // - e2eID - ID of the e2e object in the tracker @@ -154,7 +154,8 @@ type SingleUseCallbackReport struct { // Function Types // //////////////////////////////////////////////////////////////////////////////// -// Stopper is a public interface returned by Listen, allowing users to stop the registered listener. +// Stopper is a public interface returned by Listen, allowing users to stop the +// registered listener. type Stopper interface { Stop() } @@ -164,8 +165,8 @@ type Stopper interface { // // Parameters: // - callbackReport - the JSON marshalled bytes of the SingleUseCallbackReport -// object, which can be passed into WaitForRoundResult to see if the send -// succeeded. +// object, which can be passed into Cmix.WaitForRoundResult to see if the +// send succeeded. type SingleUseCallback interface { Callback(callbackReport []byte, err error) } @@ -175,8 +176,8 @@ type SingleUseCallback interface { // // Parameters: // - callbackReport - the JSON marshalled bytes of the SingleUseResponseReport -// object, which can be passed into WaitForRoundResult to see if the send -// succeeded. +// object, which can be passed into Cmix.WaitForRoundResult to see if the +// send succeeded. type SingleUseResponse interface { Callback(responseReport []byte, err error) } diff --git a/bindings/ud.go b/bindings/ud.go index 7504992f423a409b8c9e90aa97dcdbee5ce1d66c..9f17d29bbd671503c600f3eaafff02eac28048cd 100644 --- a/bindings/ud.go +++ b/bindings/ud.go @@ -105,34 +105,36 @@ type UdNetworkStatus interface { // Manager functions // //////////////////////////////////////////////////////////////////////////////// -// NewOrLoadUd loads an existing Manager from storage or creates a -// new one if there is no extant storage information. Parameters need be provided -// to specify how to connect to the User Discovery service. These parameters may be used -// to contact either the UD server hosted by the xx network team or a custom -// third-party operated server. For the former, all the information may be pulled from the -// NDF using the bindings. +// NewOrLoadUd loads an existing Manager from storage or creates a new one if +// there is no extant storage information. Parameters need be provided to +// specify how to connect to the User Discovery service. These parameters may be +// used to contact either the UD server hosted by the xx network team or a +// custom third-party operated server. For the former, all the information may +// be pulled from the NDF using the bindings. // // Params // - e2eID - e2e object ID in the tracker // - follower - network follower func wrapped in UdNetworkStatus -// - username - the username the user wants to register with UD. -// If the user is already registered, this field may be blank -// - networkValidationSig is a signature provided by the network (i.e. the client registrar). -// This may be nil, however UD may return an error in some cases (e.g. in a production level -// environment). -// - cert is the TLS certificate for the UD server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf. -// - contactFile is the data within a marshalled contact.Contact. This represents the -// contact file of the server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf. -// - address is the IP address of the UD server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf. +// - username - the username the user wants to register with UD. If the user is +// already registered, this field may be blank +// - registrationValidationSignature - a signature provided by the network +// (i.e., the client registrar). This may be nil; however, UD may return an +// error in some cases (e.g., in a production level environment). +// - cert - the TLS certificate for the UD server this call will connect with. +// You may use the UD server run by the xx network team by using +// E2e.GetUdCertFromNdf. +// - contactFile - the data within a marshalled contact.Contact. This +// represents the contact file of the server this call will connect with. You +// may use the UD server run by the xx network team by using +// E2e.GetUdContactFromNdf. +// - address - the IP address of the UD server this call will connect with. You +// may use the UD server run by the xx network team by using +// E2e.GetUdAddressFromNdf. // // Returns // - A Manager object which is registered to the specified UD service. -func NewOrLoadUd(e2eID int, follower UdNetworkStatus, - username string, registrationValidationSignature, - cert, contactFile []byte, address string) ( +func NewOrLoadUd(e2eID int, follower UdNetworkStatus, username string, + registrationValidationSignature, cert, contactFile []byte, address string) ( *UserDiscovery, error) { // Get user from singleton @@ -167,15 +169,18 @@ func NewOrLoadUd(e2eID int, follower UdNetworkStatus, // - follower - network follower func wrapped in UdNetworkStatus // - emailFactJson - nullable JSON marshalled email [fact.Fact] // - phoneFactJson - nullable JSON marshalled phone [fact.Fact] -// - cert is the TLS certificate for the UD server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdCertFromNdf. -// - contactFile is the data within a marshalled contact.Contact. This represents the -// contact file of the server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdContactFromNdf. -// - address is the IP address of the UD server this call will connect with. -// You may use the UD server run by the xx network team by using E2e.GetUdAddressFromNdf. +// - cert - the TLS certificate for the UD server this call will connect with. +// You may use the UD server run by the xx network team by using +// E2e.GetUdCertFromNdf. +// - contactFile - the data within a marshalled contact.Contact. This +// represents the contact file of the server this call will connect with. You +// may use the UD server run by the xx network team by using +// E2e.GetUdContactFromNdf. +// - address - the IP address of the UD server this call will connect with. You +// may use the UD server run by the xx network team by using +// E2e.GetUdAddressFromNdf. func NewUdManagerFromBackup(e2eID int, follower UdNetworkStatus, emailFactJson, - phoneFactJson []byte, cert, contactFile []byte, address string) (*UserDiscovery, error) { + phoneFactJson, cert, contactFile []byte, address string) (*UserDiscovery, error) { // Get user from singleton user, err := e2eTrackerSingleton.get(e2eID) @@ -229,9 +234,9 @@ func (ud *UserDiscovery) GetContact() ([]byte, error) { return ud.api.GetContact().Marshal(), nil } -// ConfirmFact confirms a fact first registered via AddFact. The confirmation ID -// comes from AddFact while the code will come over the associated -// communications system. +// ConfirmFact confirms a fact first registered via SendRegisterFact. The +// confirmation ID comes from SendRegisterFact while the code will come over the +// associated communications system. func (ud *UserDiscovery) ConfirmFact(confirmationID, code string) error { return ud.api.ConfirmFact(confirmationID, code) } @@ -309,13 +314,14 @@ type UdLookupCallback interface { // Parameters: // - e2eID - e2e object ID in the tracker // - udContact - the marshalled bytes of the contact.Contact object -// - lookupId - the marshalled bytes of the id.ID object for the user -// that LookupUD will look up. +// - lookupId - the marshalled bytes of the id.ID object for the user that +// LookupUD will look up. // - singleRequestParams - the JSON marshalled bytes of single.RequestParams // // Returns: // - []byte - the JSON marshalled bytes of the SingleUseSendReport object, -// which can be passed into WaitForRoundResult to see if the send succeeded. +// which can be passed into Cmix.WaitForRoundResult to see if the send +// succeeded. func LookupUD(e2eID int, udContact []byte, cb UdLookupCallback, lookupId []byte, singleRequestParamsJSON []byte) ([]byte, error) { @@ -390,9 +396,10 @@ type UdSearchCallback interface { // // Returns: // - []byte - the JSON marshalled bytes of the SingleUseSendReport object, -// which can be passed into WaitForRoundResult to see if the send succeeded. +// which can be passed into Cmix.WaitForRoundResult to see if the send +// succeeded. func SearchUD(e2eID int, udContact []byte, cb UdSearchCallback, - factListJSON []byte, singleRequestParamsJSON []byte) ([]byte, error) { + factListJSON, singleRequestParamsJSON []byte) ([]byte, error) { // Get user from singleton user, err := e2eTrackerSingleton.get(e2eID) diff --git a/ud/confirmFact.go b/ud/confirmFact.go index a55da37566945a03b5c0a276f92b7e30ec220f4d..1d77f357c8a1a53f7b8ed5bf6899ce696c2def01 100644 --- a/ud/confirmFact.go +++ b/ud/confirmFact.go @@ -6,8 +6,8 @@ import ( pb "gitlab.com/elixxir/comms/mixmessages" ) -// ConfirmFact confirms a fact first registered via AddFact. The -// confirmation ID comes from AddFact while the code will come over the +// ConfirmFact confirms a fact first registered via SendRegisterFact. The +// confirmation ID comes from SendRegisterFact while the code will come over the // associated communications system. func (m *Manager) ConfirmFact(confirmationID, code string) error { jww.INFO.Printf("ud.ConfirmFact(%s, %s)", confirmationID, code) diff --git a/xxdk/cmix.go b/xxdk/cmix.go index 539c2610d55f23f3b26ed7aad70e0f563148cc39..a6a715d575e35422a7c224a8b78a5b579aa7a284 100644 --- a/xxdk/cmix.go +++ b/xxdk/cmix.go @@ -341,28 +341,28 @@ func (c *Cmix) GetErrorsChannel() <-chan interfaces.ClientError { // // Threads Started: // - Network Follower (/network/follow.go) -// tracks the network events and hands them off to workers for handling. +// tracks the network events and hands them off to workers for handling. // - Historical Round Retrieval (/network/rounds/historical.go) -// retrieves data about rounds that are too old to be stored by the client. +// retrieves data about rounds that are too old to be stored by the client. // - Message Retrieval Worker Group (/network/rounds/retrieve.go) -// requests all messages in a given round from the gateway of the last -// nodes. +// requests all messages in a given round from the gateway of the last +// nodes. // - Message Handling Worker Group (/network/message/handle.go) -// decrypts and partitions messages when signals via the Switchboard. +// decrypts and partitions messages when signals via the Switchboard. // - Health Tracker (/network/health), -// via the network instance, tracks the state of the network. +// via the network instance, tracks the state of the network. // - Garbled Messages (/network/message/garbled.go) -// can be signaled to check all recent messages that could be decoded. It -// uses a message store on disk for persistence. +// can be signaled to check all recent messages that could be decoded. It +// uses a message store on disk for persistence. // - Critical Messages (/network/message/critical.go) -// ensures all protocol layer mandatory messages are sent. It uses a -// message store on disk for persistence. +// ensures all protocol layer mandatory messages are sent. It uses a +// message store on disk for persistence. // - KeyExchange Trigger (/keyExchange/trigger.go) -// responds to sent rekeys and executes them. +// responds to sent rekeys and executes them. // - KeyExchange Confirm (/keyExchange/confirm.go) -// responds to confirmations of successful rekey operations. +// responds to confirmations of successful rekey operations. // - Auth Callback (/auth/callback.go) -// handles both auth confirm and requests. +// handles both auth confirm and requests. func (c *Cmix) StartNetworkFollower(timeout time.Duration) error { jww.INFO.Printf( "StartNetworkFollower() \n\tTransmissionID: %s \n\tReceptionID: %s", @@ -375,7 +375,7 @@ func (c *Cmix) StartNetworkFollower(timeout time.Duration) error { // an error if the follower is in the wrong state to stop or if it fails to stop // it. // -// if the network follower is running and this fails, the client object will +// If the network follower is running and this fails, the client object will // most likely be in an unrecoverable state and need to be trashed. func (c *Cmix) StopNetworkFollower() error { jww.INFO.Printf("StopNetworkFollower()")