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
a753a5b6
Commit
a753a5b6
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
added the network instance
parent
6b4afd32
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/manager.go
+26
-9
26 additions, 9 deletions
network/manager.go
network/send.go
+26
-3
26 additions, 3 deletions
network/send.go
with
52 additions
and
12 deletions
network/manager.go
+
26
−
9
View file @
a753a5b6
...
@@ -15,10 +15,9 @@ import (
...
@@ -15,10 +15,9 @@ import (
"gitlab.com/elixxir/client/context/stoppable"
"gitlab.com/elixxir/client/context/stoppable"
"gitlab.com/elixxir/client/network/health"
"gitlab.com/elixxir/client/network/health"
"gitlab.com/elixxir/comms/client"
"gitlab.com/elixxir/comms/client"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/primitives/switchboard"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"
sync
"
"
gitlab.com/xx_network/primitives/ndf
"
"time"
"time"
)
)
...
@@ -37,14 +36,27 @@ type Manager struct {
...
@@ -37,14 +36,27 @@ type Manager struct {
//contains the health tracker which keeps track of if from the client's
//contains the health tracker which keeps track of if from the client's
//perspective, the network is in good condition
//perspective, the network is in good condition
health
*
health
.
Tracker
health
*
health
.
Tracker
//contains the network instance
instance
*
network
.
Instance
}
}
// NewManager builds a new reception manager object using inputted key fields
// NewManager builds a new reception manager object using inputted key fields
func
NewManager
(
ctx
*
context
.
Context
,
uid
*
id
.
ID
,
privKey
,
pubKey
,
func
NewManager
(
ctx
*
context
.
Context
,
uid
*
id
.
ID
,
privKey
,
pubKey
,
salt
[]
byte
)
(
*
Manager
,
error
)
{
salt
[]
byte
,
partial
*
ndf
.
NetworkDefinition
)
(
*
Manager
,
error
)
{
//start comms
comms
,
err
:=
client
.
NewClientComms
(
uid
,
pubKey
,
privKey
,
salt
)
comms
,
err
:=
client
.
NewClientComms
(
uid
,
pubKey
,
privKey
,
salt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
errors
.
WithMessage
(
err
,
"failed to create"
+
" client network manager"
)
}
//start network instance
instance
,
err
:=
network
.
NewInstance
(
comms
.
ProtoComms
,
partial
,
nil
,
nil
)
if
err
!=
nil
{
return
nil
,
errors
.
WithMessage
(
err
,
"failed to create"
+
" client network manager"
)
}
}
cm
:=
&
Manager
{
cm
:=
&
Manager
{
...
@@ -52,6 +64,7 @@ func NewManager(ctx *context.Context, uid *id.ID, privKey, pubKey,
...
@@ -52,6 +64,7 @@ func NewManager(ctx *context.Context, uid *id.ID, privKey, pubKey,
Context
:
ctx
,
Context
:
ctx
,
runners
:
stoppable
.
NewMulti
(
"network.Manager"
),
runners
:
stoppable
.
NewMulti
(
"network.Manager"
),
health
:
health
.
Init
(
ctx
,
5
*
time
.
Second
),
health
:
health
.
Init
(
ctx
,
5
*
time
.
Second
),
instance
:
instance
,
}
}
return
cm
,
nil
return
cm
,
nil
...
@@ -99,3 +112,7 @@ func (m *Manager) StopRunners(timeout time.Duration) error {
...
@@ -99,3 +112,7 @@ func (m *Manager) StopRunners(timeout time.Duration) error {
func
(
m
*
Manager
)
GetHealthTracker
()
context
.
HealthTracker
{
func
(
m
*
Manager
)
GetHealthTracker
()
context
.
HealthTracker
{
return
m
.
health
return
m
.
health
}
}
func
(
m
*
Manager
)
GetInstance
()
*
network
.
Instance
{
return
m
.
instance
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
network/send.go
+
26
−
3
View file @
a753a5b6
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
package
network
package
network
import
(
import
(
"github.com/pkg/errors"
"gitlab.com/elixxir/client/context/message"
"gitlab.com/elixxir/client/context/message"
"gitlab.com/elixxir/client/context/params"
"gitlab.com/elixxir/client/context/params"
"gitlab.com/elixxir/client/context/stoppable"
"gitlab.com/elixxir/client/context/stoppable"
...
@@ -18,8 +19,15 @@ import (
...
@@ -18,8 +19,15 @@ import (
// SendE2E sends an end-to-end payload to the provided recipient with
// 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 provided msgType. Returns the list of rounds in which parts of
// the message were sent or an error if it fails.
// the message were sent or an error if it fails.
func
(
m
*
Manager
)
SendE2E
(
m
message
.
Send
,
e2eP
params
.
E2E
,
cmixP
params
.
CMIX
)
(
func
(
m
*
Manager
)
SendE2E
(
m
sg
message
.
Send
,
e2eP
params
.
E2E
,
cmixP
params
.
CMIX
)
(
[]
id
.
Round
,
error
)
{
[]
id
.
Round
,
error
)
{
if
!
m
.
health
.
IsRunning
()
{
return
nil
,
errors
.
New
(
"Cannot send e2e message when the "
+
"network is not healthy"
)
}
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -36,6 +44,21 @@ func (m *Manager) SendUnsafe(m message.Send) ([]id.Round, error) {
...
@@ -36,6 +44,21 @@ func (m *Manager) SendUnsafe(m message.Send) ([]id.Round, error) {
// recipient. Note that both SendE2E and SendUnsafe call SendCMIX.
// recipient. Note that both SendE2E and SendUnsafe call SendCMIX.
// Returns the round ID of the round the payload was sent or an error
// Returns the round ID of the round the payload was sent or an error
// if it fails.
// if it fails.
func
(
m
*
Manager
)
SendCMIX
(
message
format
.
Message
)
(
id
.
Round
,
error
)
{
func
(
m
*
Manager
)
SendCMIX
(
msg
format
.
Message
)
(
id
.
Round
,
error
)
{
return
nil
,
nil
if
!
m
.
health
.
IsRunning
()
{
return
0
,
errors
.
New
(
"Cannot send cmix message when the "
+
"network is not healthy"
)
}
return
m
.
sendCMIX
(
msg
)
}
// Internal send e2e which bypasses the network check, for use in SendE2E and
// SendUnsafe which do their own network checks
func
(
m
*
Manager
)
sendCMIX
(
message
format
.
Message
)
(
id
.
Round
,
error
)
{
//get the round to send on
m
.
return
0
,
nil
}
}
\ No newline at end of file
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