Skip to content
Snippets Groups Projects
Commit 02e461dd authored by Josh Brooks's avatar Josh Brooks
Browse files

Standardize sub-interfaces in ud/

parent a65ba4b6
No related branches found
No related tags found
2 merge requests!510Release,!280Standardize sub-interfaces in ud/
......@@ -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
......@@ -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) (
......
......@@ -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()
}
......
......@@ -25,7 +25,7 @@ import (
)
///////////////////////////////////////////////////////////////////////////////
// Mock of the E2E interface within this package //////////////////////////////
// Mock of the udE2e interface within this package //////////////////////////////
///////////////////////////////////////////////////////////////////////////////
type mockE2e struct {
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment