From 3ef87e8c794c860bffd2ea8830a38146e430654f Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Mon, 25 Jul 2022 10:22:07 -0700
Subject: [PATCH] Refactor various NewClient functions to NewCmix

---
 backup/backupRestore.go | 4 ++--
 cmd/backup.go           | 2 +-
 cmd/precan.go           | 2 +-
 cmd/proto.go            | 2 +-
 xxdk/cmix.go            | 8 ++++----
 xxdk/precan.go          | 6 +++---
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/backup/backupRestore.go b/backup/backupRestore.go
index 94e1180ae..be59b29f7 100644
--- a/backup/backupRestore.go
+++ b/backup/backupRestore.go
@@ -20,12 +20,12 @@ import (
 	"gitlab.com/xx_network/primitives/id"
 )
 
-// NewClientFromBackup initializes a new e2e storage from an encrypted
+// NewCmixFromBackup initializes a new e2e storage from an encrypted
 // backup. The backup is decrypted using the backupPassphrase. On
 // a successful client creation, the function will return a
 // JSON encoded list of the E2E partners contained in the backup and a
 // json-encoded string containing parameters stored in the backup
-func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
+func NewCmixFromBackup(ndfJSON, storageDir string, sessionPassword,
 	backupPassphrase []byte, backupFileContents []byte) ([]*id.ID,
 	string, error) {
 
diff --git a/cmd/backup.go b/cmd/backup.go
index e6df9a991..2499dacbf 100644
--- a/cmd/backup.go
+++ b/cmd/backup.go
@@ -50,7 +50,7 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
 		}
 
 		// Construct cMix from backup data
-		backupIdList, _, err := backup.NewClientFromBackup(string(ndfJson), storeDir,
+		backupIdList, _, err := backup.NewCmixFromBackup(string(ndfJson), storeDir,
 			password, []byte(backupPass), backupFile)
 		if err != nil {
 			jww.FATAL.Panicf("%+v", err)
diff --git a/cmd/precan.go b/cmd/precan.go
index c7155d19e..4f607c6b1 100644
--- a/cmd/precan.go
+++ b/cmd/precan.go
@@ -35,7 +35,7 @@ func loadOrInitPrecan(precanId uint, password []byte, storeDir string,
 			jww.FATAL.Panicf("%+v", err)
 		}
 
-		err = xxdk.NewPrecannedClient(precanId, string(ndfJson), storeDir, password)
+		err = xxdk.NewPrecannedCmix(precanId, string(ndfJson), storeDir, password)
 		if err != nil {
 			jww.FATAL.Panicf("%+v", err)
 		}
diff --git a/cmd/proto.go b/cmd/proto.go
index e42abd37a..129ff1b08 100644
--- a/cmd/proto.go
+++ b/cmd/proto.go
@@ -44,7 +44,7 @@ func loadOrInitProto(protoUserPath string, password []byte, storeDir string,
 			jww.FATAL.Panicf("%v", err)
 		}
 
-		err = xxdk.NewProtoClient_Unsafe(string(ndfJson), storeDir,
+		err = xxdk.NewProtoCmix_Unsafe(string(ndfJson), storeDir,
 			password, protoUser)
 		if err != nil {
 			jww.FATAL.Panicf("%+v", err)
diff --git a/xxdk/cmix.go b/xxdk/cmix.go
index a3a798055..6dfe2e540 100644
--- a/xxdk/cmix.go
+++ b/xxdk/cmix.go
@@ -154,12 +154,12 @@ func OpenCmix(storageDir string, password []byte) (*Cmix, error) {
 	return c, nil
 }
 
-// NewProtoClient_Unsafe initializes a client object from a JSON containing
+// NewProtoCmix_Unsafe initializes a client object from a JSON containing
 // predefined cryptographic that defines a user. This is designed for some
 // specific deployment procedures and is generally unsafe.
-func NewProtoClient_Unsafe(ndfJSON, storageDir string, password []byte,
+func NewProtoCmix_Unsafe(ndfJSON, storageDir string, password []byte,
 	protoUser *user.Proto) error {
-	jww.INFO.Printf("NewProtoClient_Unsafe")
+	jww.INFO.Printf("NewProtoCmix_Unsafe")
 
 	usr := user.NewUserFromProto(protoUser)
 
@@ -556,7 +556,7 @@ func DecodeGroups(ndf *ndf.NetworkDefinition) (cmixGrp, e2eGrp *cyclic.Group) {
 
 // CheckVersionAndSetupStorage checks the client version and creates a new
 // storage for user data. This function is common code shared by NewCmix,
-//// NewPrecannedClient and NewVanityCmix.
+//// NewPrecannedCmix and NewVanityCmix.
 func CheckVersionAndSetupStorage(def *ndf.NetworkDefinition, storageDir string,
 	password []byte, userInfo user.Info, cmixGrp, e2eGrp *cyclic.Group,
 	registrationCode string) (storage.Session, error) {
diff --git a/xxdk/precan.go b/xxdk/precan.go
index 98437456b..12e7bee31 100644
--- a/xxdk/precan.go
+++ b/xxdk/precan.go
@@ -22,14 +22,14 @@ import (
 	"gitlab.com/xx_network/crypto/csprng"
 )
 
-// NewPrecannedClient creates an insecure user with predetermined keys with
+// NewPrecannedCmix creates an insecure user with predetermined keys with
 // nodes. It 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.
-func NewPrecannedClient(precannedID uint, defJSON, storageDir string,
+func NewPrecannedCmix(precannedID uint, defJSON, storageDir string,
 	password []byte) error {
-	jww.INFO.Printf("NewPrecannedClient()")
+	jww.INFO.Printf("NewPrecannedCmix()")
 	rngStreamGen := fastRNG.NewStreamGenerator(12, 1024,
 		csprng.NewSystemRNG)
 	rngStream := rngStreamGen.GetStream()
-- 
GitLab