From d78a196bed1c21162d15b2f680b479adac66ca76 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Thu, 26 May 2022 13:48:33 -0700 Subject: [PATCH] Privatize sub-interfaces --- cmix/interface.go | 2 +- cmix/nodes/interfaces.go | 8 ++++---- cmix/nodes/register.go | 6 +++--- cmix/nodes/registrar.go | 8 ++++---- cmix/nodes/request.go | 6 +++--- cmix/nodes/utils_test.go | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmix/interface.go b/cmix/interface.go index c03dc1296..863530bff 100644 --- a/cmix/interface.go +++ b/cmix/interface.go @@ -299,5 +299,5 @@ type ClientErrorReport func(source, message, trace string) type clientCommsInterface interface { followNetworkComms SendCmixCommsInterface - nodes.RegisterNodeCommsInterface + nodes.registerNodeCommsInterface } diff --git a/cmix/nodes/interfaces.go b/cmix/nodes/interfaces.go index 35a16cbe2..34824da33 100644 --- a/cmix/nodes/interfaces.go +++ b/cmix/nodes/interfaces.go @@ -62,16 +62,16 @@ type MixCypher interface { MakeClientGatewayAuthMAC(salt, digest []byte) []byte } -// RegisterNodeCommsInterface is a sub-interface of client.Comms containing +// registerNodeCommsInterface is a sub-interface of client.Comms containing // the send function for registering with a cMix node. -type RegisterNodeCommsInterface interface { +type registerNodeCommsInterface interface { SendRequestClientKeyMessage(host *connect.Host, message *pb.SignedClientKeyRequest) (*pb.SignedKeyResponse, error) } -// Session is a sub-interface of the storage.Session interface relevant to +// session is a sub-interface of the storage.Session interface relevant to // the methods used in this package. -type Session interface { +type session interface { GetTransmissionID() *id.ID IsPrecanned() bool GetCmixGroup() *cyclic.Group diff --git a/cmix/nodes/register.go b/cmix/nodes/register.go index 3d03fe456..f225cef16 100644 --- a/cmix/nodes/register.go +++ b/cmix/nodes/register.go @@ -30,7 +30,7 @@ import ( // The sync.Map's keep track of the node(s) that were in progress // before an interruption and how many registration attempts have // been attempted. -func registerNodes(r *registrar, s Session, stop *stoppable.Single, +func registerNodes(r *registrar, s session, stop *stoppable.Single, inProgress, attempts *sync.Map) { interval := time.Duration(500) * time.Millisecond @@ -114,8 +114,8 @@ func registerNodes(r *registrar, s Session, stop *stoppable.Single, // registerWithNode serves as a helper for registerNodes. It registers a user // with a specific in the client's NDF. -func registerWithNode(sender gateway.Sender, comms RegisterNodeCommsInterface, - ngw network.NodeGateway, s Session, r *registrar, +func registerWithNode(sender gateway.Sender, comms registerNodeCommsInterface, + ngw network.NodeGateway, s session, r *registrar, rng csprng.Source, stop *stoppable.Single) error { nodeID, err := ngw.Node.GetNodeId() diff --git a/cmix/nodes/registrar.go b/cmix/nodes/registrar.go index 23f859915..1d076e525 100644 --- a/cmix/nodes/registrar.go +++ b/cmix/nodes/registrar.go @@ -34,9 +34,9 @@ type registrar struct { kv *versioned.KV mux sync.RWMutex - session Session + session session sender gateway.Sender - comms RegisterNodeCommsInterface + comms registerNodeCommsInterface rng *fastRNG.StreamGenerator c chan network.NodeGateway @@ -44,8 +44,8 @@ type registrar struct { // LoadRegistrar loads a Registrar from disk or creates a new one if it does not // exist. -func LoadRegistrar(session Session, sender gateway.Sender, - comms RegisterNodeCommsInterface, rngGen *fastRNG.StreamGenerator, +func LoadRegistrar(session session, sender gateway.Sender, + comms registerNodeCommsInterface, rngGen *fastRNG.StreamGenerator, c chan network.NodeGateway) (Registrar, error) { kv := session.GetKV().Prefix(prefix) diff --git a/cmix/nodes/request.go b/cmix/nodes/request.go index fe251e46a..a172c2824 100644 --- a/cmix/nodes/request.go +++ b/cmix/nodes/request.go @@ -26,8 +26,8 @@ import ( // requestKey is a helper function which constructs a ClientKeyRequest message. // This message is sent to the passed gateway. It will further handle the // request from the gateway. -func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface, - ngw network.NodeGateway, s Session, r *registrar, +func requestKey(sender gateway.Sender, comms registerNodeCommsInterface, + ngw network.NodeGateway, s session, r *registrar, rng io.Reader, stop *stoppable.Single) (*cyclic.Int, []byte, uint64, error) { @@ -92,7 +92,7 @@ func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface, // makeSignedKeyRequest is a helper function which constructs a // pb.SignedClientKeyRequest to send to the node/gateway pair the // user is trying to register with. -func makeSignedKeyRequest(s Session, rng io.Reader, +func makeSignedKeyRequest(s session, rng io.Reader, gwId *id.ID, dhPub *cyclic.Int) (*pb.SignedClientKeyRequest, error) { // Reconstruct client confirmation message diff --git a/cmix/nodes/utils_test.go b/cmix/nodes/utils_test.go index 2c1169c38..895999b6f 100644 --- a/cmix/nodes/utils_test.go +++ b/cmix/nodes/utils_test.go @@ -145,7 +145,7 @@ func (m mockSender) GetHostParams() connect.HostParams { } /////////////////////////////////////////////////////////////////////////////// -///////////////// Mock storage.Session Interface ////////////////////////////// +///////////////// Mock storage.session Interface ////////////////////////////// /////////////////////////////////////////////////////////////////////////////// type mockSession struct { @@ -192,7 +192,7 @@ func (m mockSession) GetTransmissionRegistrationValidationSignature() []byte { ///////////////// Mock Comms Interface /////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// Mock client comms object adhering to RegisterNodeCommsInterface for testing. +// Mock client comms object adhering to registerNodeCommsInterface for testing. type MockClientComms struct { rsaPrivKey *rsa.PrivateKey dhPrivKey *cyclic.Int -- GitLab