Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
7edf36da
Commit
7edf36da
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Invert NewOrLoadUd naming scheme
parent
ad08cd8d
No related branches found
No related tags found
2 merge requests
!510
Release
,
!323
Xx 4019/new or load alt ud
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/ud.go
+3
-3
3 additions, 3 deletions
bindings/ud.go
cmd/ud.go
+1
-1
1 addition, 1 deletion
cmd/ud.go
ud/manager.go
+21
-18
21 additions, 18 deletions
ud/manager.go
with
25 additions
and
22 deletions
bindings/ud.go
+
3
−
3
View file @
7edf36da
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
cmd/ud.go
+
1
−
1
View file @
7edf36da
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
ud/manager.go
+
21
−
18
View file @
7edf36da
...
...
@@ -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,11 +128,10 @@ 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.
...
...
@@ -144,11 +147,11 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus,
//
// 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment