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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
18cac607
Commit
18cac607
authored
Sep 22, 2020
by
Richard T. Carback III
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/peppa/newClient' into XX-2656/newload
parents
90de21ce
5e42cfd3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
context/networkManager.go
+4
-0
4 additions, 0 deletions
context/networkManager.go
network/manager.go
+15
-34
15 additions, 34 deletions
network/manager.go
network/send.go
+8
-8
8 additions, 8 deletions
network/send.go
with
27 additions
and
42 deletions
context/networkManager.go
+
4
−
0
View file @
18cac607
...
...
@@ -3,6 +3,7 @@ package context
import
(
"gitlab.com/elixxir/client/context/message"
"gitlab.com/elixxir/client/context/params"
"gitlab.com/elixxir/client/context/stoppable"
"gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id"
...
...
@@ -14,6 +15,9 @@ type NetworkManager interface {
SendCMIX
(
message
format
.
Message
,
p
params
.
CMIX
)
(
id
.
Round
,
error
)
GetInstance
()
*
network
.
Instance
GetHealthTracker
()
HealthTracker
RegisterWithPermissioning
(
string
)
([]
byte
,
error
)
GetRemoteVersion
()
(
string
,
error
)
GetStoppable
()
stoppable
.
Stoppable
}
type
HealthTracker
interface
{
...
...
This diff is collapsed.
Click to expand it.
network/manager.go
+
15
−
34
View file @
18cac607
...
...
@@ -33,10 +33,6 @@ import (
// Manager implements the NetworkManager interface inside context. It
// controls access to network resources and implements all of the communications
// functions used by the client.
type
Manager
struct
{
m
manager
}
type
manager
struct
{
// parameters of the network
param
params
.
Network
...
...
@@ -53,7 +49,7 @@ type manager struct {
}
// NewManager builds a new reception manager object using inputted key fields
func
NewManager
(
ctx
*
context
.
Context
,
params
params
.
Network
,
ndf
*
ndf
.
NetworkDefinition
)
(
*
Manager
,
error
)
{
func
NewManager
(
ctx
*
context
.
Context
,
params
params
.
Network
,
ndf
*
ndf
.
NetworkDefinition
)
(
context
.
Network
Manager
,
error
)
{
//get the user from storage
user
:=
ctx
.
Session
.
User
()
...
...
@@ -97,18 +93,18 @@ func NewManager(ctx *context.Context, params params.Network, ndf *ndf.NetworkDef
m
.
message
=
message
.
NewManager
(
m
.
Internal
,
m
.
param
.
Messages
,
m
.
NodeRegistration
)
m
.
round
=
rounds
.
NewManager
(
m
.
Internal
,
m
.
param
.
Rounds
,
m
.
message
.
GetMessageReceptionChannel
())
return
&
Manager
{
m
:
m
}
,
nil
return
&
m
,
nil
}
// GetRemoteVersion contacts the permissioning server and returns the current
// supported client version.
func
(
m
*
M
anager
)
GetRemoteVersion
()
(
string
,
error
)
{
permissioningHost
,
ok
:=
m
.
m
.
Comms
.
GetHost
(
&
id
.
Permissioning
)
func
(
m
*
m
anager
)
GetRemoteVersion
()
(
string
,
error
)
{
permissioningHost
,
ok
:=
m
.
Comms
.
GetHost
(
&
id
.
Permissioning
)
if
!
ok
{
return
""
,
errors
.
Errorf
(
"no permissioning host with id %s"
,
id
.
Permissioning
)
}
registrationVersion
,
err
:=
m
.
m
.
Comms
.
SendGetCurrentClientVersionMessage
(
registrationVersion
,
err
:=
m
.
Comms
.
SendGetCurrentClientVersionMessage
(
permissioningHost
)
if
err
!=
nil
{
return
""
,
err
...
...
@@ -116,12 +112,8 @@ func (m *Manager) GetRemoteVersion() (string, error) {
return
registrationVersion
.
Version
,
nil
}
func
(
m
*
Manager
)
StartRunners
()
error
{
return
m
.
m
.
startRunners
()
}
// StartRunners kicks off all network reception goroutines ("threads").
func
(
m
*
manager
)
s
tartRunners
()
error
{
func
(
m
*
manager
)
S
tartRunners
()
error
{
if
m
.
runners
.
IsRunning
()
{
return
errors
.
Errorf
(
"network routines are already running"
)
}
...
...
@@ -152,34 +144,23 @@ func (m *manager) startRunners() error {
return
nil
}
func
(
m
*
Manager
)
RegisterWithPermissioning
(
registrationCode
string
)
([]
byte
,
error
)
{
pubKey
:=
m
.
m
.
Session
.
User
()
.
GetCryptographicIdentity
()
.
GetRSA
()
.
GetPublic
()
return
permissioning
.
Register
(
m
.
m
.
Comms
,
pubKey
,
registrationCode
)
}
// GetRunners returns the network goroutines such that they can be named
// and stopped.
func
(
m
*
Manager
)
GetRunners
()
stoppable
.
Stoppable
{
return
m
.
m
.
runners
func
(
m
*
manager
)
RegisterWithPermissioning
(
registrationCode
string
)
([]
byte
,
error
)
{
pubKey
:=
m
.
Session
.
User
()
.
GetCryptographicIdentity
()
.
GetRSA
()
.
GetPublic
()
return
permissioning
.
Register
(
m
.
Comms
,
pubKey
,
registrationCode
)
}
// StopRunners stops all the reception goroutines
func
(
m
*
M
anager
)
GetStoppable
()
stoppable
.
Stoppable
{
return
m
.
m
.
runners
func
(
m
*
m
anager
)
GetStoppable
()
stoppable
.
Stoppable
{
return
m
.
runners
}
// GetHealthTracker returns the health tracker
func
(
m
*
M
anager
)
GetHealthTracker
()
context
.
HealthTracker
{
return
m
.
m
.
Health
func
(
m
*
m
anager
)
GetHealthTracker
()
context
.
HealthTracker
{
return
m
.
Health
}
// GetInstance returns the network instance object (ndf state)
func
(
m
*
M
anager
)
GetInstance
()
*
network
.
Instance
{
return
m
.
m
.
Instance
func
(
m
*
m
anager
)
GetInstance
()
*
network
.
Instance
{
return
m
.
Instance
}
// GetNodeRegistrationCh returns node registration channel for node
// events.
func
(
m
*
Manager
)
GetNodeRegistrationCh
()
chan
network
.
NodeGateway
{
return
m
.
m
.
NodeRegistration
}
This diff is collapsed.
Click to expand it.
network/send.go
+
8
−
8
View file @
18cac607
...
...
@@ -13,13 +13,13 @@ import (
// recipient. Note that both SendE2E and SendUnsafe call SendCMIX.
// Returns the round ID of the round the payload was sent or an error
// if it fails.
func
(
m
*
M
anager
)
SendCMIX
(
msg
format
.
Message
,
param
params
.
CMIX
)
(
id
.
Round
,
error
)
{
if
!
m
.
m
.
Health
.
IsRunning
()
{
func
(
m
*
m
anager
)
SendCMIX
(
msg
format
.
Message
,
param
params
.
CMIX
)
(
id
.
Round
,
error
)
{
if
!
m
.
Health
.
IsRunning
()
{
return
0
,
errors
.
New
(
"Cannot send cmix message when the "
+
"network is not healthy"
)
}
return
m
.
m
.
message
.
SendCMIX
(
msg
,
param
)
return
m
.
message
.
SendCMIX
(
msg
,
param
)
}
// SendUnsafe sends an unencrypted payload to the provided recipient
...
...
@@ -27,8 +27,8 @@ func (m *Manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, err
// of the message were sent or an error if it fails.
// NOTE: Do not use this function unless you know what you are doing.
// This function always produces an error message in client logging.
func
(
m
*
M
anager
)
SendUnsafe
(
msg
message
.
Send
,
param
params
.
Unsafe
)
([]
id
.
Round
,
error
)
{
if
!
m
.
m
.
Health
.
IsRunning
()
{
func
(
m
*
m
anager
)
SendUnsafe
(
msg
message
.
Send
,
param
params
.
Unsafe
)
([]
id
.
Round
,
error
)
{
if
!
m
.
Health
.
IsRunning
()
{
return
nil
,
errors
.
New
(
"cannot send unsafe message when the "
+
"network is not healthy"
)
}
...
...
@@ -43,13 +43,13 @@ func (m *Manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round,
// SendE2E sends an end-to-end payload to the provided recipient with
// the provided msgType. Returns the list of rounds in which parts of
// the message were sent or an error if it fails.
func
(
m
*
M
anager
)
SendE2E
(
msg
message
.
Send
,
e2eP
params
.
E2E
)
(
func
(
m
*
m
anager
)
SendE2E
(
msg
message
.
Send
,
e2eP
params
.
E2E
)
(
[]
id
.
Round
,
error
)
{
if
!
m
.
m
.
Health
.
IsRunning
()
{
if
!
m
.
Health
.
IsRunning
()
{
return
nil
,
errors
.
New
(
"Cannot send e2e message when the "
+
"network is not healthy"
)
}
return
m
.
m
.
message
.
SendE2E
(
msg
,
e2eP
)
return
m
.
message
.
SendE2E
(
msg
,
e2eP
)
}
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