diff --git a/ud/interfaces.go b/ud/interfaces.go index c6507f2bb244ad003df9e47cb99c4aed285988b7..5b35c7d973442a67fc9f4247ab567893ddceb9ba 100644 --- a/ud/interfaces.go +++ b/ud/interfaces.go @@ -20,11 +20,9 @@ type UserInfo interface { GetReceptionRegistrationValidationSignature() []byte } -// FollowerService is an interface for the api.Client's +// NetworkStatus is an interface for the api.Client's // NetworkFollowerStatus method. -type FollowerService interface { - NetworkFollowerStatus() api.Status -} +type NetworkStatus func() api.Status // todo: this may not be needed. if so, remove. type SingleInterface interface { diff --git a/ud/lookup.go b/ud/lookup.go index 4ad72cc51144fe8ed47694d04f9c68315d1f4eb1..599a3230ae8031054552fc6dc62243cc9bbbd4ec 100644 --- a/ud/lookup.go +++ b/ud/lookup.go @@ -27,12 +27,10 @@ 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(udContact contact.Contact, - services cmix.Client, - callback lookupCallback, - rng *fastRNG.StreamGenerator, - uid *id.ID, grp *cyclic.Group, - timeout time.Duration) (id.Round, +func Lookup(services cmix.Client, + rng *fastRNG.StreamGenerator, grp *cyclic.Group, + udContact contact.Contact, callback lookupCallback, + uid *id.ID, timeout time.Duration) (id.Round, receptionID.EphemeralIdentity, error) { jww.INFO.Printf("ud.Lookup(%s, %s)", uid, timeout) @@ -51,7 +49,7 @@ func BatchLookup(udContact contact.Contact, for _, uid := range uids { go func(localUid *id.ID) { - rid, ephId, err := lookup(services, rng, localUid, grp, + _, _, err := lookup(services, rng, localUid, grp, timeout, udContact, callback) if err != nil { jww.WARN.Printf("Failed batch lookup on user %s: %v", @@ -143,4 +141,4 @@ func (m lookupResponse) Callback(payload []byte, } go m.cb(c, nil) -} \ No newline at end of file +} diff --git a/ud/manager.go b/ud/manager.go index 16b9edbfd5deec067139b44b3ae342b7d8596724..66f20301e9f2766e4775941a464e60a1c0b50bc9 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -9,7 +9,7 @@ import ( "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/event" "gitlab.com/elixxir/client/storage/versioned" - store "gitlab.com/elixxir/client/ud/store/ud" + store "gitlab.com/elixxir/client/ud/store" "gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/primitives/fact" @@ -56,16 +56,17 @@ type alternateUd struct { dhPubKey []byte } -// NewManager builds a new user discovery manager. It requires that an updated +// NewManager builds a new user discovery manager. +// It requires that an updated // NDF is available and will error if one is not. -// todo: docstring, organize the order of arguments in a meaningful way -func NewManager(services cmix.Client, e2e e2e.Handler, follower FollowerService, +func NewManager(services cmix.Client, e2e e2e.Handler, + follower NetworkStatus, events *event.Manager, comms Comms, userStore UserInfo, rng *fastRNG.StreamGenerator, username string, kv *versioned.KV) (*Manager, error) { jww.INFO.Println("ud.NewManager()") - if follower.NetworkFollowerStatus() != api.Running { + if follower() != api.Running { return nil, errors.New( "cannot start UD Manager when network follower is not running.") } @@ -121,12 +122,12 @@ func NewManager(services cmix.Client, e2e e2e.Handler, follower FollowerService, // It will construct a manager that is already registered and restore // already registered facts into store. func NewManagerFromBackup(services cmix.Client, - follower FollowerService, - e2e e2e.Handler, events *event.Manager, comms Comms, + e2e e2e.Handler, follower NetworkStatus, + events *event.Manager, comms Comms, userStore UserInfo, rng *fastRNG.StreamGenerator, email, phone fact.Fact, kv *versioned.KV) (*Manager, error) { jww.INFO.Println("ud.NewManagerFromBackup()") - if follower.NetworkFollowerStatus() != api.Running { + if follower() != api.Running { return nil, errors.New( "cannot start UD Manager when " + "network follower is not running.") diff --git a/ud/search.go b/ud/search.go index 4e48731bc51e60982ccb8c6a84205931e0a01642..9814c27bd8dce28d99339f0864e1526ef508375a 100644 --- a/ud/search.go +++ b/ud/search.go @@ -33,11 +33,10 @@ 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(list fact.FactList, - services cmix.Client, events *event.Manager, - callback searchCallback, - rng *fastRNG.StreamGenerator, udContact contact.Contact, - grp *cyclic.Group, timeout time.Duration) (id.Round, +func Search(services cmix.Client, events *event.Manager, + rng *fastRNG.StreamGenerator, grp *cyclic.Group, + udContact contact.Contact, callback searchCallback, + list fact.FactList, timeout time.Duration) (id.Round, receptionID.EphemeralIdentity, error) { jww.INFO.Printf("ud.Search(%s, %s)", list.Stringify(), timeout)