Skip to content
Snippets Groups Projects
Commit 619c839d authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

made the number of parallel node registrations configurable and made

it default of 8 to speed up registration with a large network
parent 006a86d9
Branches
Tags
No related merge requests found
...@@ -21,6 +21,8 @@ type Network struct { ...@@ -21,6 +21,8 @@ type Network struct {
// Longest delay between network events for Health tracker to denote that // Longest delay between network events for Health tracker to denote that
// the network is in a bad state // the network is in a bad state
NetworkHealthTimeout time.Duration NetworkHealthTimeout time.Duration
//Number of parallel node registration the client is capable of
ParallelNodeRegistrations uint
Rounds Rounds
Messages Messages
...@@ -36,6 +38,7 @@ func GetDefaultNetwork() Network { ...@@ -36,6 +38,7 @@ func GetDefaultNetwork() Network {
RegNodesBufferLen: 500, RegNodesBufferLen: 500,
NetworkHealthTimeout: 30 * time.Second, NetworkHealthTimeout: 30 * time.Second,
E2EParams: GetDefaultE2ESessionParams(), E2EParams: GetDefaultE2ESessionParams(),
ParallelNodeRegistrations: 8,
} }
n.Rounds = GetDefaultRounds() n.Rounds = GetDefaultRounds()
n.Messages = GetDefaultMessage() n.Messages = GetDefaultMessage()
......
...@@ -124,7 +124,7 @@ func (m *manager) Follow(report interfaces.ClientErrorReport) (stoppable.Stoppab ...@@ -124,7 +124,7 @@ func (m *manager) Follow(report interfaces.ClientErrorReport) (stoppable.Stoppab
// Node Updates // Node Updates
multi.Add(node.StartRegistration(m.Instance, m.Session, m.Rng, multi.Add(node.StartRegistration(m.Instance, m.Session, m.Rng,
m.Comms, m.NodeRegistration)) // Adding/Keys m.Comms, m.NodeRegistration, m.param.ParallelNodeRegistrations)) // Adding/Keys
//TODO-remover //TODO-remover
//m.runners.Add(StartNodeRemover(m.Context)) // Removing //m.runners.Add(StartNodeRemover(m.Context)) // Removing
......
...@@ -41,14 +41,20 @@ type RegisterNodeCommsInterface interface { ...@@ -41,14 +41,20 @@ type RegisterNodeCommsInterface interface {
} }
func StartRegistration(instance *network.Instance, session *storage.Session, rngGen *fastRNG.StreamGenerator, comms RegisterNodeCommsInterface, func StartRegistration(instance *network.Instance, session *storage.Session, rngGen *fastRNG.StreamGenerator, comms RegisterNodeCommsInterface,
c chan network.NodeGateway) stoppable.Stoppable { c chan network.NodeGateway, numParallel uint) stoppable.Stoppable {
stop := stoppable.NewSingle("NodeRegistration")
multi := stoppable.NewMulti("NodeRegistrations")
instance.SetAddGatewayChan(c) instance.SetAddGatewayChan(c)
for i:=uint(0);i<numParallel;i++{
stop := stoppable.NewSingle(fmt.Sprintf("NodeRegistration %d", i))
go registerNodes(session, rngGen, comms, stop, c) go registerNodes(session, rngGen, comms, stop, c)
multi.Add(stop)
}
return stop return multi
} }
func registerNodes(session *storage.Session, rngGen *fastRNG.StreamGenerator, comms RegisterNodeCommsInterface, func registerNodes(session *storage.Session, rngGen *fastRNG.StreamGenerator, comms RegisterNodeCommsInterface,
...@@ -74,7 +80,6 @@ func registerNodes(session *storage.Session, rngGen *fastRNG.StreamGenerator, co ...@@ -74,7 +80,6 @@ func registerNodes(session *storage.Session, rngGen *fastRNG.StreamGenerator, co
case <-t.C: case <-t.C:
} }
} }
} }
//registerWithNode serves as a helper for RegisterWithNodes //registerWithNode serves as a helper for RegisterWithNodes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment