diff --git a/ud/interfaces.go b/ud/interfaces.go index 42b0c570f5ff522bcb2b8204ad867b4b08fd9b4a..addd3a5303c42f7d6e3ce5ddd075e6a43e14ed6d 100644 --- a/ud/interfaces.go +++ b/ud/interfaces.go @@ -10,17 +10,21 @@ import ( "gitlab.com/elixxir/crypto/fastRNG" ) -// CMix is a sub-interface of the cmix.Client. It contains the methods +////////////////////////////////////////////////////////////////////////////////////// +// UD sub-interfaces +///////////////////////////////////////////////////////////////////////////////////// + +// udCmix is a sub-interface of the cmix.Client. It contains the methods // relevant to what is used in this package. -type CMix interface { - // CMix is passed down into the single use package, - // and thus has to adhere to the sub-interface defined in that package +type udCmix interface { + // Cmix within the single package is what udCmix must adhere to when passing + // arguments through to methods in the single package. single.Cmix } -// E2E is a sub-interface of the xxdk.E2e. It contains the methods +// udE2e is a sub-interface of the xxdk.E2e. It contains the methods // relevant to what is used in this package. -type E2E interface { +type udE2e interface { GetReceptionIdentity() xxdk.ReceptionIdentity GetCmix() cmix.Client GetE2E() e2e.Handler @@ -30,6 +34,6 @@ type E2E interface { GetTransmissionIdentity() xxdk.TransmissionIdentity } -// NetworkStatus is an interface for the xxdk.Cmix's +// udNetworkStatus is an interface for the xxdk.Cmix's // NetworkFollowerStatus method. -type NetworkStatus func() xxdk.Status +type udNetworkStatus func() xxdk.Status diff --git a/ud/lookup.go b/ud/lookup.go index bdcf557b8ebffd2bd21b75e7ed7ba20d58dedd54..6f23a8ccd91ac4eb7c76f1c3a71787717695e0b3 100644 --- a/ud/lookup.go +++ b/ud/lookup.go @@ -22,21 +22,21 @@ type lookupCallback func(contact.Contact, error) // Lookup returns the public key of the passed ID as known by the user discovery // system or returns by the timeout. -func Lookup(services CMix, +func Lookup(net udCmix, rng csprng.Source, grp *cyclic.Group, udContact contact.Contact, callback lookupCallback, uid *id.ID, p single.RequestParams) ([]id.Round, receptionID.EphemeralIdentity, error) { jww.INFO.Printf("ud.Lookup(%s, %s)", uid, p.Timeout) - return lookup(services, rng, uid, grp, udContact, callback, p) + return lookup(net, rng, uid, grp, udContact, callback, p) } // BatchLookup performs a Lookup operation on a list of user IDs. // The lookup performs a callback on each lookup on the returned contact object // constructed from the response. func BatchLookup(udContact contact.Contact, - services CMix, callback lookupCallback, + net udCmix, callback lookupCallback, rng csprng.Source, uids []*id.ID, grp *cyclic.Group, p single.RequestParams) { @@ -44,7 +44,7 @@ func BatchLookup(udContact contact.Contact, for _, uid := range uids { go func(localUid *id.ID) { - _, _, err := lookup(services, rng, localUid, grp, + _, _, err := lookup(net, rng, localUid, grp, udContact, callback, p) if err != nil { jww.WARN.Printf("Failed batch lookup on user %s: %v", @@ -59,7 +59,7 @@ func BatchLookup(udContact contact.Contact, // lookup is a helper function which sends a lookup request to the user discovery // service. It will construct a contact object off of the returned public key. // The callback will be called on that contact object. -func lookup(net CMix, rng csprng.Source, uid *id.ID, +func lookup(net udCmix, rng csprng.Source, uid *id.ID, grp *cyclic.Group, udContact contact.Contact, callback lookupCallback, p single.RequestParams) ( diff --git a/ud/manager.go b/ud/manager.go index 026583cb43bbd2b000ca49a1b693b92e6bb2dfe4..922e264e0471eb1a20d8f59b27fa38ba49126bdb 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -29,7 +29,7 @@ type Manager struct { // e2e is a sub-interface of the e2e.Handler. It allows the Manager // to retrieve the client's E2E information. - e2e E2E + e2e udE2e // store is an instantiation of this package's storage object. // It contains the facts that are in some state of being registered @@ -58,7 +58,7 @@ type Manager struct { // It requires that an updated // NDF is available and will error if one is not. // registrationValidationSignature may be set to nil -func NewManager(e2e E2E, comms Comms, follower NetworkStatus, +func NewManager(e2e udE2e, comms Comms, follower udNetworkStatus, username string, registrationValidationSignature []byte) (*Manager, error) { jww.INFO.Println("ud.NewManager()") @@ -113,7 +113,7 @@ func NewManager(e2e E2E, comms Comms, follower NetworkStatus, // NewManagerFromBackup builds a new user discover manager from a backup. // It will construct a manager that is already registered and restore // already registered facts into store. -func NewManagerFromBackup(e2e E2E, comms Comms, follower NetworkStatus, +func NewManagerFromBackup(e2e udE2e, comms Comms, follower udNetworkStatus, email, phone fact.Fact) (*Manager, error) { jww.INFO.Println("ud.NewManagerFromBackup()") if follower() != xxdk.Running { @@ -188,7 +188,7 @@ func InitStoreFromBackup(kv *versioned.KV, // LoadManager loads the state of the Manager // from disk. This is meant to be called after any the first // instantiation of the manager by NewUserDiscovery. -func LoadManager(e2e E2E, comms Comms) (*Manager, error) { +func LoadManager(e2e udE2e, comms Comms) (*Manager, error) { m := &Manager{ e2e: e2e, comms: comms, @@ -318,7 +318,7 @@ func (m *Manager) getOrAddUdHost() (*connect.Host, error) { // getCmix retrieve a sub-interface of cmix.Client. // It allows the Manager to retrieve network state. -func (m *Manager) getCmix() CMix { +func (m *Manager) getCmix() udCmix { return m.e2e.GetCmix() } diff --git a/ud/mockE2e_test.go b/ud/mockE2e_test.go index 103d7e1362eeebfdec403a741044f6610918cff0..3be9c745ab0e44bfe413029872e3c9d28d007df6 100644 --- a/ud/mockE2e_test.go +++ b/ud/mockE2e_test.go @@ -25,7 +25,7 @@ import ( ) /////////////////////////////////////////////////////////////////////////////// -// Mock of the E2E interface within this package ////////////////////////////// +// Mock of the udE2e interface within this package ////////////////////////////// /////////////////////////////////////////////////////////////////////////////// type mockE2e struct { diff --git a/ud/networkManager_test.go b/ud/networkManager_test.go index 8aaec9115ab25ee3870dbff16afe3aa62670bbe8..3af69d9efaab5db21c45ea17f46c21313bb4e197 100644 --- a/ud/networkManager_test.go +++ b/ud/networkManager_test.go @@ -18,7 +18,7 @@ import ( "time" ) -// testNetworkManager is a mock implementation of the CMix interface. +// testNetworkManager is a mock implementation of the udCmix interface. type testNetworkManager struct { requestProcess message.Processor instance *network.Instance diff --git a/ud/search.go b/ud/search.go index 7061f4cc3a5c0b1c463b665a06f7cc9b3d70bdaf..473ba7a7fabfb754669726c92063fda1cec52658 100644 --- a/ud/search.go +++ b/ud/search.go @@ -28,7 +28,7 @@ type searchCallback func([]contact.Contact, error) // used to search for multiple users at once; that can have a privacy reduction. // Instead, it is intended to be used to search for a user where multiple pieces // of information is known. -func Search(services CMix, events event.Reporter, +func Search(net udCmix, events event.Reporter, rng csprng.Source, grp *cyclic.Group, udContact contact.Contact, callback searchCallback, list fact.FactList, @@ -48,7 +48,7 @@ func Search(services CMix, events event.Reporter, response := searchResponse{ cb: callback, - services: services, + services: net, events: events, grp: grp, factMap: factMap, @@ -56,7 +56,7 @@ func Search(services CMix, events event.Reporter, rndId, ephId, err := single.TransmitRequest(udContact, SearchTag, requestMarshaled, - response, params, services, rng, grp) + response, params, net, rng, grp) if err != nil { return []id.Round{}, receptionID.EphemeralIdentity{}, errors.WithMessage(err, "Failed to transmit search request.") @@ -72,7 +72,7 @@ func Search(services CMix, events event.Reporter, type searchResponse struct { cb searchCallback - services CMix + services udCmix events event.Reporter grp *cyclic.Group factMap map[string]fact.Fact