Skip to content
Snippets Groups Projects
Commit 18cac607 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

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
...@@ -3,6 +3,7 @@ package context ...@@ -3,6 +3,7 @@ package context
import ( import (
"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/comms/network" "gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
...@@ -14,6 +15,9 @@ type NetworkManager interface { ...@@ -14,6 +15,9 @@ type NetworkManager interface {
SendCMIX(message format.Message, p params.CMIX) (id.Round, error) SendCMIX(message format.Message, p params.CMIX) (id.Round, error)
GetInstance() *network.Instance GetInstance() *network.Instance
GetHealthTracker() HealthTracker GetHealthTracker() HealthTracker
RegisterWithPermissioning(string) ([]byte, error)
GetRemoteVersion() (string, error)
GetStoppable() stoppable.Stoppable
} }
type HealthTracker interface { type HealthTracker interface {
......
...@@ -33,10 +33,6 @@ import ( ...@@ -33,10 +33,6 @@ import (
// Manager implements the NetworkManager interface inside context. It // Manager implements the NetworkManager interface inside context. It
// controls access to network resources and implements all of the communications // controls access to network resources and implements all of the communications
// functions used by the client. // functions used by the client.
type Manager struct {
m manager
}
type manager struct { type manager struct {
// parameters of the network // parameters of the network
param params.Network param params.Network
...@@ -53,7 +49,7 @@ type manager struct { ...@@ -53,7 +49,7 @@ type manager struct {
} }
// 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, params params.Network, ndf *ndf.NetworkDefinition) (*Manager, error) { func NewManager(ctx *context.Context, params params.Network, ndf *ndf.NetworkDefinition) (context.NetworkManager, error) {
//get the user from storage //get the user from storage
user := ctx.Session.User() user := ctx.Session.User()
...@@ -97,18 +93,18 @@ func NewManager(ctx *context.Context, params params.Network, ndf *ndf.NetworkDef ...@@ -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.message = message.NewManager(m.Internal, m.param.Messages, m.NodeRegistration)
m.round = rounds.NewManager(m.Internal, m.param.Rounds, m.message.GetMessageReceptionChannel()) 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 // GetRemoteVersion contacts the permissioning server and returns the current
// supported client version. // supported client version.
func (m *Manager) GetRemoteVersion() (string, error) { func (m *manager) GetRemoteVersion() (string, error) {
permissioningHost, ok := m.m.Comms.GetHost(&id.Permissioning) permissioningHost, ok := m.Comms.GetHost(&id.Permissioning)
if !ok { if !ok {
return "", errors.Errorf("no permissioning host with id %s", return "", errors.Errorf("no permissioning host with id %s",
id.Permissioning) id.Permissioning)
} }
registrationVersion, err := m.m.Comms.SendGetCurrentClientVersionMessage( registrationVersion, err := m.Comms.SendGetCurrentClientVersionMessage(
permissioningHost) permissioningHost)
if err != nil { if err != nil {
return "", err return "", err
...@@ -116,12 +112,8 @@ func (m *Manager) GetRemoteVersion() (string, error) { ...@@ -116,12 +112,8 @@ func (m *Manager) GetRemoteVersion() (string, error) {
return registrationVersion.Version, nil return registrationVersion.Version, nil
} }
func (m *Manager) StartRunners() error {
return m.m.startRunners()
}
// StartRunners kicks off all network reception goroutines ("threads"). // StartRunners kicks off all network reception goroutines ("threads").
func (m *manager) startRunners() error { func (m *manager) StartRunners() error {
if m.runners.IsRunning() { if m.runners.IsRunning() {
return errors.Errorf("network routines are already running") return errors.Errorf("network routines are already running")
} }
...@@ -152,34 +144,23 @@ func (m *manager) startRunners() error { ...@@ -152,34 +144,23 @@ func (m *manager) startRunners() error {
return nil return nil
} }
func (m *Manager) RegisterWithPermissioning(registrationCode string) ([]byte, error) { func (m *manager) RegisterWithPermissioning(registrationCode string) ([]byte, error) {
pubKey := m.m.Session.User().GetCryptographicIdentity().GetRSA().GetPublic() pubKey := m.Session.User().GetCryptographicIdentity().GetRSA().GetPublic()
return permissioning.Register(m.m.Comms, pubKey, registrationCode) return permissioning.Register(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
} }
// StopRunners stops all the reception goroutines // StopRunners stops all the reception goroutines
func (m *Manager) GetStoppable() stoppable.Stoppable { func (m *manager) GetStoppable() stoppable.Stoppable {
return m.m.runners return m.runners
} }
// GetHealthTracker returns the health tracker // GetHealthTracker returns the health tracker
func (m *Manager) GetHealthTracker() context.HealthTracker { func (m *manager) GetHealthTracker() context.HealthTracker {
return m.m.Health return m.Health
} }
// GetInstance returns the network instance object (ndf state) // GetInstance returns the network instance object (ndf state)
func (m *Manager) GetInstance() *network.Instance { func (m *manager) GetInstance() *network.Instance {
return m.m.Instance return m.Instance
} }
// GetNodeRegistrationCh returns node registration channel for node
// events.
func (m *Manager) GetNodeRegistrationCh() chan network.NodeGateway {
return m.m.NodeRegistration
}
...@@ -13,13 +13,13 @@ import ( ...@@ -13,13 +13,13 @@ import (
// 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(msg format.Message, param params.CMIX) (id.Round, error) { func (m *manager) SendCMIX(msg format.Message, param params.CMIX) (id.Round, error) {
if !m.m.Health.IsRunning() { if !m.Health.IsRunning() {
return 0, errors.New("Cannot send cmix message when the " + return 0, errors.New("Cannot send cmix message when the " +
"network is not healthy") "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 // 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 ...@@ -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. // of the message were sent or an error if it fails.
// NOTE: Do not use this function unless you know what you are doing. // NOTE: Do not use this function unless you know what you are doing.
// This function always produces an error message in client logging. // This function always produces an error message in client logging.
func (m *Manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, error) { func (m *manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, error) {
if !m.m.Health.IsRunning() { if !m.Health.IsRunning() {
return nil, errors.New("cannot send unsafe message when the " + return nil, errors.New("cannot send unsafe message when the " +
"network is not healthy") "network is not healthy")
} }
...@@ -43,13 +43,13 @@ func (m *Manager) SendUnsafe(msg message.Send, param params.Unsafe) ([]id.Round, ...@@ -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 // 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(msg message.Send, e2eP params.E2E) ( func (m *manager) SendE2E(msg message.Send, e2eP params.E2E) (
[]id.Round, error) { []id.Round, error) {
if !m.m.Health.IsRunning() { if !m.Health.IsRunning() {
return nil, errors.New("Cannot send e2e message when the " + return nil, errors.New("Cannot send e2e message when the " +
"network is not healthy") "network is not healthy")
} }
return m.m.message.SendE2E(msg, e2eP) return m.message.SendE2E(msg, e2eP)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment