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
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!323
Xx 4019/new or load alt ud
Changes
3
Hide 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,
...
@@ -130,7 +130,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus,
}
}
// Build manager
// Build manager
u
,
err
:=
ud
.
LoadOrNewManager
(
user
.
api
,
user
.
api
.
GetComms
(),
u
,
err
:=
ud
.
NewOrLoadFromNdf
(
user
.
api
,
user
.
api
.
GetComms
(),
UdNetworkStatusFn
,
username
,
registrationValidationSignature
)
UdNetworkStatusFn
,
username
,
registrationValidationSignature
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -141,7 +141,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus,
...
@@ -141,7 +141,7 @@ func LoadOrNewUserDiscovery(e2eID int, follower UdNetworkStatus,
}
}
// LoadOrNewAlternateUserDiscovery loads an existing Manager from storage or creates a
// 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.
// 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
// 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.
// xx network team, one the user or a third-party may operate.
...
@@ -177,7 +177,7 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus,
...
@@ -177,7 +177,7 @@ func LoadOrNewAlternateUserDiscovery(e2eID int, follower UdNetworkStatus,
}
}
// Build manager
// Build manager
u
,
err
:=
ud
.
LoadOrNewAlternateUserDiscovery
(
user
.
api
,
user
.
api
.
GetComms
(),
u
,
err
:=
ud
.
NewOrLoad
(
user
.
api
,
user
.
api
.
GetComms
(),
UdNetworkStatusFn
,
username
,
registrationValidationSignature
,
UdNetworkStatusFn
,
username
,
registrationValidationSignature
,
altCert
,
altAddress
,
marshalledContact
)
altCert
,
altAddress
,
marshalledContact
)
if
err
!=
nil
{
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{
...
@@ -63,7 +63,7 @@ var udCmd = &cobra.Command{
// Make user discovery manager
// Make user discovery manager
userToRegister
:=
viper
.
GetString
(
udRegisterFlag
)
userToRegister
:=
viper
.
GetString
(
udRegisterFlag
)
jww
.
TRACE
.
Printf
(
"[UD] Registering identity %v..."
,
userToRegister
)
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
)
user
.
NetworkFollowerStatus
,
userToRegister
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to load or create new UD manager: %+v"
,
err
)
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 {
...
@@ -43,20 +43,23 @@ type Manager struct {
alternativeUd
*
alternateUd
alternativeUd
*
alternateUd
}
}
// LoadOrNewManager loads an existing Manager from storage or creates a
// NewOrLoadFromNdf loads an existing Manager from storage or creates a
// new one if there is no extant storage information.
// 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
// Params
// - user is an interface that adheres to the xxdk.E2e object.
// - user is an interface that adheres to the xxdk.E2e object.
// - comms is an interface that adheres to client.Comms 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.
// - 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
// - username is the name of the user as it is registered with UD. This will be what
// provides if through the bindings.
// the end user provides if through the bindings.
// - networkValidationSig is a signature provided by the network (i.e. the client registrar). This may
// - networkValidationSig is a signature provided by the network (i.e. the client registrar).
// be nil, however UD may return an error in some cases (e.g. in a production level environment).
// This may be nil, however UD may return an error in some cases (e.g. in a production level
func
LoadOrNewManager
(
user
udE2e
,
comms
Comms
,
follower
udNetworkStatus
,
// environment).
func
NewOrLoadFromNdf
(
user
udE2e
,
comms
Comms
,
follower
udNetworkStatus
,
username
string
,
networkValidationSig
[]
byte
)
(
*
Manager
,
error
)
{
username
string
,
networkValidationSig
[]
byte
)
(
*
Manager
,
error
)
{
jww
.
INFO
.
Println
(
"ud.
LoadOrNewManager
()"
)
jww
.
INFO
.
Println
(
"ud.
NewOrLoadFromNdf
()"
)
// Construct manager
// Construct manager
m
,
err
:=
loadOrNewManager
(
user
,
comms
,
follower
)
m
,
err
:=
loadOrNewManager
(
user
,
comms
,
follower
)
...
@@ -77,7 +80,8 @@ func LoadOrNewManager(user udE2e, comms Comms, follower udNetworkStatus,
...
@@ -77,7 +80,8 @@ func LoadOrNewManager(user udE2e, comms Comms, follower udNetworkStatus,
// NewManagerFromBackup builds a new user discover manager from a backup.
// NewManagerFromBackup builds a new user discover manager from a backup.
// It will construct a manager that is already registered and restore
// 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
,
func
NewManagerFromBackup
(
user
udE2e
,
comms
Comms
,
follower
udNetworkStatus
,
email
,
phone
fact
.
Fact
)
(
*
Manager
,
error
)
{
email
,
phone
fact
.
Fact
)
(
*
Manager
,
error
)
{
jww
.
INFO
.
Println
(
"ud.NewManagerFromBackup()"
)
jww
.
INFO
.
Println
(
"ud.NewManagerFromBackup()"
)
...
@@ -124,31 +128,30 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus,
...
@@ -124,31 +128,30 @@ func NewManagerFromBackup(user udE2e, comms Comms, follower udNetworkStatus,
return
m
,
nil
return
m
,
nil
}
}
// LoadOrNewAlternateUserDiscovery loads an existing Manager from storage or creates a
// NewOrLoad 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 call allows the user to provide
// in that it allows the user to provide alternate User Discovery contact information.
// custom UD contact information. These parameters may be used to contact a separate UD server
// These parameters may be used to contact a separate UD server than the one run by the
// than the one hosted by the xx network team, i.e. one the user or a third-party may operate.
// xx network team, one the user or a third-party may operate.
//
//
// Params
// Params
// - user is an interface that adheres to the xxdk.E2e object.
// - user is an interface that adheres to the xxdk.E2e object.
// - comms is an interface that adheres to client.Comms 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.
// - 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
// - 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
// - 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.
// - altCert is the TLS certificate for the alternate UD server.
// - altAddress is the IP address of the alternate UD server.
// - altAddress is the IP address of the alternate UD server.
// - marshalledContact is the data within a marshalled contact.Contact.
// - marshalledContact is the data within a marshalled contact.Contact.
//
//
// Returns
// Returns
// - A Manager object which is registered to the specified alternate UD service.
// - 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
,
username
string
,
networkValidationSig
[]
byte
,
altCert
,
altAddress
,
marshalledContact
[]
byte
)
(
*
Manager
,
error
)
{
marshalledContact
[]
byte
)
(
*
Manager
,
error
)
{
jww
.
INFO
.
Println
(
"ud.
LoadOrNewAlternateUserDiscovery
()"
)
jww
.
INFO
.
Println
(
"ud.
NewOrLoad
()"
)
// Construct manager
// Construct manager
m
,
err
:=
loadOrNewManager
(
user
,
comms
,
follower
)
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