From 6f37dc4cb9ff35dbb566097616213d6a5f218bc2 Mon Sep 17 00:00:00 2001
From: jbhusson <jonah@elixxir.io>
Date: Tue, 19 Jul 2022 16:53:55 -0400
Subject: [PATCH] Make naming more consistent

---
 bindings/cmix.go     | 16 ++++++++--------
 bindings/e2e.go      | 12 ++++++------
 bindings/follow.go   | 10 +++++-----
 bindings/identity.go |  8 ++++----
 connect/connect.go   |  8 ++++----
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/bindings/cmix.go b/bindings/cmix.go
index e22bb9364..ea2fbaa22 100644
--- a/bindings/cmix.go
+++ b/bindings/cmix.go
@@ -29,36 +29,36 @@ var cmixTrackerSingleton = &cmixTracker{
 	count:   0,
 }
 
-// Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions
+// Cmix wraps the xxdk.Cmix struct, implementing additional functions
 // to support the gomobile Cmix interface
 type Cmix struct {
 	api *xxdk.Cmix
 	id  int
 }
 
-// NewKeystore creates client storage, generates keys, connects, and registers
+// NewCmix creates client storage, generates keys, connects, and registers
 // with the network. Note that this does not register a username/identity, but
 // merely creates a new cryptographic identity for adding such information
 // at a later date.
 //
 // Users of this function should delete the storage directory on error.
-func NewKeystore(network, storageDir string, password []byte, regCode string) error {
-	if err := xxdk.NewCmix(network, storageDir, password, regCode); err != nil {
+func NewCmix(ndfJSON, storageDir string, password []byte, registrationCode string) error {
+	if err := xxdk.NewCmix(ndfJSON, storageDir, password, registrationCode); err != nil {
 		return errors.New(fmt.Sprintf("Failed to create new client: %+v",
 			err))
 	}
 	return nil
 }
 
-// Login will load an existing client from the storageDir
+// LoadCmix will load an existing client from the storageDir
 // using the password. This will fail if the client doesn't exist or
 // the password is incorrect.
 // The password is passed as a byte array so that it can be cleared from
 // memory and stored as securely as possible using the memguard library.
-// Login does not block on network connection, and instead loads and
+// LoadCmix does not block on network connection, and instead loads and
 // starts subprocesses to perform network operations.
 // TODO: add in custom parameters instead of the default
-func Login(storageDir string, password []byte, cmixParamsJSON []byte) (*Cmix,
+func LoadCmix(storageDir string, password []byte, cmixParamsJSON []byte) (*Cmix,
 	error) {
 	if len(cmixParamsJSON) == 0 {
 		jww.WARN.Printf("cmix params not specified, using defaults...")
@@ -72,7 +72,7 @@ func Login(storageDir string, password []byte, cmixParamsJSON []byte) (*Cmix,
 
 	client, err := xxdk.LoadCmix(storageDir, password, params)
 	if err != nil {
-		return nil, errors.New(fmt.Sprintf("Failed to login: %+v", err))
+		return nil, errors.New(fmt.Sprintf("LoadCmix failed: %+v", err))
 	}
 
 	return cmixTrackerSingleton.make(client), nil
diff --git a/bindings/e2e.go b/bindings/e2e.go
index c2ddab490..43d185608 100644
--- a/bindings/e2e.go
+++ b/bindings/e2e.go
@@ -37,10 +37,10 @@ func (e *E2e) GetID() int {
 	return e.id
 }
 
-// LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton
-// identity should be created via MakeIdentity() and passed in here
+// Login creates and returns a new E2e object and adds it to the e2eTrackerSingleton
+// identity should be created via MakeReceptionIdentity() and passed in here
 // If callbacks is left nil, a default auth.Callbacks will be used
-func LoginE2e(cmixId int, callbacks AuthCallbacks, identity,
+func Login(cmixId int, callbacks AuthCallbacks, identity,
 	e2eParamsJSON []byte) (*E2e, error) {
 	if len(e2eParamsJSON) == 0 {
 		jww.WARN.Printf("e2e params not specified, using defaults...")
@@ -77,10 +77,10 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity,
 	return e2eTrackerSingleton.make(newE2e), nil
 }
 
-// LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton
-// identity should be created via MakeIdentity() and passed in here
+// LoginEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton
+// identity should be created via MakeReceptionIdentity() and passed in here
 // If callbacks is left nil, a default auth.Callbacks will be used
-func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity,
+func LoginEphemeral(cmixId int, callbacks AuthCallbacks, identity,
 	e2eParamsJSON []byte) (*E2e, error) {
 	if len(e2eParamsJSON) == 0 {
 		jww.WARN.Printf("e2e params not specified, using defaults...")
diff --git a/bindings/follow.go b/bindings/follow.go
index 98eb78467..874882c81 100644
--- a/bindings/follow.go
+++ b/bindings/follow.go
@@ -94,9 +94,9 @@ func (c *Cmix) HasRunningProcessies() bool {
 	return c.api.HasRunningProcessies()
 }
 
-// IsNetworkHealthy returns true if the network is read to be in a healthy state where
+// IsHealthy returns true if the network is read to be in a healthy state where
 // messages can be sent
-func (c *Cmix) IsNetworkHealthy() bool {
+func (c *Cmix) IsHealthy() bool {
 	return c.api.GetCmix().IsHealthy()
 }
 
@@ -106,14 +106,14 @@ type NetworkHealthCallback interface {
 	Callback(bool)
 }
 
-// RegisterNetworkHealthCB registers the network health callback to be called
+// AddHealthCallback registers the network health callback to be called
 // any time the network health changes. Returns a unique ID that can be used to
 // unregister the network health callback.
-func (c *Cmix) RegisterNetworkHealthCB(nhc NetworkHealthCallback) int64 {
+func (c *Cmix) AddHealthCallback(nhc NetworkHealthCallback) int64 {
 	return int64(c.api.GetCmix().AddHealthCallback(nhc.Callback))
 }
 
-func (c *Cmix) UnregisterNetworkHealthCB(funcID int64) {
+func (c *Cmix) RemoveHealthCallback(funcID int64) {
 	c.api.GetCmix().RemoveHealthCallback(uint64(funcID))
 }
 
diff --git a/bindings/identity.go b/bindings/identity.go
index 39665ca28..c3e470df4 100644
--- a/bindings/identity.go
+++ b/bindings/identity.go
@@ -32,8 +32,8 @@ type ReceptionIdentity struct {
 	DHKeyPrivate  []byte
 }
 
-// MakeIdentity generates a new cryptographic identity for receiving messages
-func (c *Cmix) MakeIdentity() ([]byte, error) {
+// MakeReceptionIdentity generates a new cryptographic identity for receiving messages
+func (c *Cmix) MakeReceptionIdentity() ([]byte, error) {
 	ident, err := xxdk.MakeReceptionIdentity(c.api)
 	if err != nil {
 		return nil, err
@@ -42,8 +42,8 @@ func (c *Cmix) MakeIdentity() ([]byte, error) {
 	return ident.Marshal()
 }
 
-// MakeLegacyIdentity generates the legacy identity for receiving messages
-func (c *Cmix) MakeLegacyIdentity() ([]byte, error) {
+// MakeLegacyReceptionIdentity generates the legacy identity for receiving messages
+func (c *Cmix) MakeLegacyReceptionIdentity() ([]byte, error) {
 	ident, err := xxdk.MakeLegacyReceptionIdentity(c.api)
 	if err != nil {
 		return nil, err
diff --git a/connect/connect.go b/connect/connect.go
index ea755c0b1..f6aace42d 100644
--- a/connect/connect.go
+++ b/connect/connect.go
@@ -127,8 +127,8 @@ func Connect(recipient contact.Contact, messenger *xxdk.E2e,
 // no requests are missed.
 // This call does an xxDK.ephemeralLogin under the hood and the connection
 // server must be the only listener on auth.
-func StartServer(identity xxdk.ReceptionIdentity, cb Callback, net *xxdk.Cmix,
-	p xxdk.E2EParams, clParams ConnectionListParams) (*ConnectionServer, error) {
+func StartServer(identity xxdk.ReceptionIdentity, connectionCallback Callback,
+	net *xxdk.Cmix, params xxdk.E2EParams, clParams ConnectionListParams) (*ConnectionServer, error) {
 
 	// Create connection list and start cleanup thread
 	cl := NewConnectionList(clParams)
@@ -138,9 +138,9 @@ func StartServer(identity xxdk.ReceptionIdentity, cb Callback, net *xxdk.Cmix,
 	}
 
 	// Build callback for E2E negotiation
-	callback := getServerAuthCallback(nil, cb, cl, p)
+	callback := getServerAuthCallback(nil, connectionCallback, cl, params)
 
-	e2eClient, err := xxdk.LoginEphemeral(net, callback, identity, p)
+	e2eClient, err := xxdk.LoginEphemeral(net, callback, identity, params)
 	if err != nil {
 		return nil, err
 	}
-- 
GitLab