From 13d8b4f0724a024601512a4919110c5254be0e57 Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Wed, 6 Jul 2022 18:55:51 +0000
Subject: [PATCH] Fix name of authenticatedConnection and merge the (internal)
 tracker code into it.

---
 ...nnection.go => authenticatedConnection.go} | 52 +++++++++++++++++
 bindings/authenticatedConnectionTracker.go    | 56 -------------------
 2 files changed, 52 insertions(+), 56 deletions(-)
 rename bindings/{autheticatedConnection.go => authenticatedConnection.go} (53%)
 delete mode 100644 bindings/authenticatedConnectionTracker.go

diff --git a/bindings/autheticatedConnection.go b/bindings/authenticatedConnection.go
similarity index 53%
rename from bindings/autheticatedConnection.go
rename to bindings/authenticatedConnection.go
index 837580897..ce33daf0e 100644
--- a/bindings/autheticatedConnection.go
+++ b/bindings/authenticatedConnection.go
@@ -1,6 +1,9 @@
 package bindings
 
 import (
+	"sync"
+
+	"github.com/pkg/errors"
 	"gitlab.com/elixxir/client/connect"
 	"gitlab.com/elixxir/crypto/contact"
 )
@@ -46,3 +49,52 @@ func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*A
 		e2eClient.api, params)
 	return authenticatedConnectionTrackerSingleton.make(connection), err
 }
+
+// connectionTracker is a singleton used to keep track of extant clients, allowing
+// for race condition free passing over the bindings
+
+type authenticatedConnectionTracker struct {
+	connections map[int]*AuthenticatedConnection
+	count       int
+	mux         sync.RWMutex
+}
+
+// make makes a client from an API client, assigning it a unique ID
+func (act *authenticatedConnectionTracker) make(c connect.AuthenticatedConnection) *AuthenticatedConnection {
+	act.mux.Lock()
+	defer act.mux.Unlock()
+
+	id := act.count
+	act.count++
+
+	act.connections[id] = &AuthenticatedConnection{
+		Connection: Connection{
+			connection: c,
+			id:         id,
+		},
+	}
+
+	return act.connections[id]
+}
+
+//get returns a client given its ID
+func (act *authenticatedConnectionTracker) get(id int) (*AuthenticatedConnection, error) {
+	act.mux.RLock()
+	defer act.mux.RUnlock()
+
+	c, exist := act.connections[id]
+	if !exist {
+		return nil, errors.Errorf("Cannot get client for id %d, client "+
+			"does not exist", id)
+	}
+
+	return c, nil
+}
+
+//deletes a client if it exists
+func (act *authenticatedConnectionTracker) delete(id int) {
+	act.mux.Lock()
+	defer act.mux.Unlock()
+
+	delete(act.connections, id)
+}
diff --git a/bindings/authenticatedConnectionTracker.go b/bindings/authenticatedConnectionTracker.go
deleted file mode 100644
index 57e260dc7..000000000
--- a/bindings/authenticatedConnectionTracker.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package bindings
-
-import (
-	"github.com/pkg/errors"
-	"gitlab.com/elixxir/client/connect"
-	"sync"
-)
-
-// connectionTracker is a singleton used to keep track of extant clients, allowing
-// for race condition free passing over the bindings
-
-type authenticatedConnectionTracker struct {
-	connections map[int]*AuthenticatedConnection
-	count       int
-	mux         sync.RWMutex
-}
-
-// make makes a client from an API client, assigning it a unique ID
-func (act *authenticatedConnectionTracker) make(c connect.AuthenticatedConnection) *AuthenticatedConnection {
-	act.mux.Lock()
-	defer act.mux.Unlock()
-
-	id := act.count
-	act.count++
-
-	act.connections[id] = &AuthenticatedConnection{
-		Connection: Connection{
-			connection: c,
-			id:         id,
-		},
-	}
-
-	return act.connections[id]
-}
-
-//get returns a client given its ID
-func (act *authenticatedConnectionTracker) get(id int) (*AuthenticatedConnection, error) {
-	act.mux.RLock()
-	defer act.mux.RUnlock()
-
-	c, exist := act.connections[id]
-	if !exist {
-		return nil, errors.Errorf("Cannot get client for id %d, client "+
-			"does not exist", id)
-	}
-
-	return c, nil
-}
-
-//deletes a client if it exists
-func (act *authenticatedConnectionTracker) delete(id int) {
-	act.mux.Lock()
-	defer act.mux.Unlock()
-
-	delete(act.connections, id)
-}
-- 
GitLab