diff --git a/bindings/ud.go b/bindings/ud.go index 89ffcc0614cf15f41ab921eeeced374aba08fa63..d33dbc85fd2a459d9ff1660728703236ed062e00 100644 --- a/bindings/ud.go +++ b/bindings/ud.go @@ -130,7 +130,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, } // Build manager - u, err := ud.LoadOrNewManager(user.api, user.api.GetComms(), + u, err := ud.NewOrLoadFromNdf(user.api, user.api.GetComms(), UdNetworkStatusFn, username, registrationValidationSignature) if err != nil { return nil, err @@ -141,7 +141,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus, } // LoadOrNewAlternateUserDiscovery loads an existing Manager from storage or creates a -// new one if there is no extant storage information. This is different from LoadOrNewManager +// new one if there is no extant storage information. This is different from NewOrLoadFromNdf // in that it allows the user to provide alternate User Discovery contact information. // These parameters may be used to contact a separate UD server than the one run by the // xx network team, one the user or a third-party may operate. @@ -177,7 +177,7 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus, } // Build manager - u, err := ud.LoadOrNewAlternateUserDiscovery(user.api, user.api.GetComms(), + u, err := ud.NewOrLoad(user.api, user.api.GetComms(), UdNetworkStatusFn, username, registrationValidationSignature, altCert, altAddress, marshalledContact) if err != nil { diff --git a/cmd/ud.go b/cmd/ud.go index 10d423889ff8c1dcc2a363ad821af820db76beaa..fc950c9526293d097a7ad620c1dc1e641c0bc281 100644 --- a/cmd/ud.go +++ b/cmd/ud.go @@ -63,7 +63,7 @@ var udCmd = &cobra.Command{ // Make user discovery manager userToRegister := viper.GetString(udRegisterFlag) jww.TRACE.Printf("[UD] Registering identity %v...", userToRegister) - userDiscoveryMgr, err := ud.LoadOrNewManager(user, user.GetComms(), + userDiscoveryMgr, err := ud.NewOrLoadFromNdf(user, user.GetComms(), user.NetworkFollowerStatus, userToRegister, nil) if err != nil { jww.FATAL.Panicf("Failed to load or create new UD manager: %+v", err) diff --git a/ud/manager.go b/ud/manager.go index c1d51d00202bef9847220bcfd19376724e898378..6106e2ebf519f04fe61bbb0d07cc9a6a5852a630 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -43,20 +43,23 @@ type Manager struct { alternativeUd *alternateUd } -// LoadOrNewManager loads an existing Manager from storage or creates a -// new one if there is no extant storage information. +// NewOrLoadFromNdf loads an existing Manager from storage or creates a +// new one if there is no extant storage information. This will default to connecting with +// the xx network's UD server as found in the NDF. For connecting to a custom server, use +// NewOrLoad. // // Params // - user is an interface that adheres to the xxdk.E2e object. // - comms is an interface that adheres to client.Comms object. // - follower is a method off of xxdk.Cmix which returns the network follower's status. -// - username is the name of the user as it is registered with UD. This will be what the end user -// provides if through the bindings. -// - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may -// be nil, however UD may return an error in some cases (e.g. in a production level environment). -func LoadOrNewManager(user udE2e, comms Comms, follower udNetworkStatus, +// - username is the name of the user as it is registered with UD. This will be what +// the end user provides if through the bindings. +// - networkValidationSig is a signature provided by the network (i.e. the client registrar). +// This may be nil, however UD may return an error in some cases (e.g. in a production level +// environment). +func NewOrLoadFromNdf(user udE2e, comms Comms, follower udNetworkStatus, username string, networkValidationSig []byte) (*Manager, error) { - jww.INFO.Println("ud.LoadOrNewManager()") + jww.INFO.Println("ud.NewOrLoadFromNdf()") // Construct manager m, err := loadOrNewManager(user, comms, follower) @@ -77,7 +80,8 @@ func LoadOrNewManager(user udE2e, comms Comms, follower udNetworkStatus, // 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. +// already registered facts into store. This will default to using the UD server as defined +// by the NDF> func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, email, phone fact.Fact) (*Manager, error) { jww.INFO.Println("ud.NewManagerFromBackup()") @@ -124,31 +128,30 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus, return m, nil } -// LoadOrNewAlternateUserDiscovery loads an existing Manager from storage or creates a -// new one if there is no extant storage information. This is different from LoadOrNewManager -// in that it allows the user to provide alternate User Discovery contact information. -// These parameters may be used to contact a separate UD server than the one run by the -// xx network team, one the user or a third-party may operate. +// NewOrLoad loads an existing Manager from storage or creates a +// new one if there is no extant storage information. This call allows the user to provide +// custom UD contact information. These parameters may be used to contact a separate UD server +// than the one hosted by the xx network team, i.e. one the user or a third-party may operate. // // Params // - user is an interface that adheres to the xxdk.E2e object. // - comms is an interface that adheres to client.Comms object. // - follower is a method off of xxdk.Cmix which returns the network follower's status. // - username is the name of the user as it is registered with UD. This will be what the end user -// provides if through the bindings. +// provides if through the bindings. // - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may -// be nil, however UD may return an error in some cases (e.g. in a production level environment). +// be nil, however UD may return an error in some cases (e.g. in a production level environment). // - altCert is the TLS certificate for the alternate UD server. // - altAddress is the IP address of the alternate UD server. // - marshalledContact is the data within a marshalled contact.Contact. // // Returns // - A Manager object which is registered to the specified alternate UD service. -func LoadOrNewAlternateUserDiscovery(user udE2e, comms Comms, follower udNetworkStatus, +func NewOrLoad(user udE2e, comms Comms, follower udNetworkStatus, username string, networkValidationSig []byte, altCert, altAddress, marshalledContact []byte) (*Manager, error) { - jww.INFO.Println("ud.LoadOrNewAlternateUserDiscovery()") + jww.INFO.Println("ud.NewOrLoad()") // Construct manager m, err := loadOrNewManager(user, comms, follower)