mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
swarm: worked in feedback comments to PR
This commit is contained in:
parent
87b35debce
commit
b1bd66d71e
1 changed files with 12 additions and 6 deletions
|
|
@ -103,8 +103,14 @@ func startStop(net *Network, quit chan struct{}, nodeCount int) {
|
|||
func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
|
||||
nodes, err := connectNodesInRing(net, nodeCount)
|
||||
if err != nil {
|
||||
select {
|
||||
case <-quit:
|
||||
//error may be due to abortion of mocking; so the quit channel is closed
|
||||
return
|
||||
default:
|
||||
panic("Could not startup node network for mocker")
|
||||
}
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-quit:
|
||||
|
|
@ -144,7 +150,7 @@ func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
|
|||
log.Debug(fmt.Sprintf("node %v shutting down", nodes[i]))
|
||||
err := net.Stop(nodes[i])
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Error stopping node %s", nodes[i]))
|
||||
log.Error("Error stopping node", "node", nodes[i])
|
||||
wg.Done()
|
||||
continue
|
||||
}
|
||||
|
|
@ -152,7 +158,7 @@ func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
|
|||
time.Sleep(randWait)
|
||||
err := net.Start(id)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Error starting node %s", id))
|
||||
log.Error("Error starting node", "node", id)
|
||||
}
|
||||
wg.Done()
|
||||
}(nodes[i])
|
||||
|
|
@ -169,7 +175,7 @@ func connectNodesInRing(net *Network, nodeCount int) ([]discover.NodeID, error)
|
|||
conf := adapters.RandomNodeConfig()
|
||||
node, err := net.NewNodeWithConfig(conf)
|
||||
if err != nil {
|
||||
log.Error("Error creating a node! %s", err)
|
||||
log.Error("Error creating a node!", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
ids[i] = node.ID()
|
||||
|
|
@ -177,7 +183,7 @@ func connectNodesInRing(net *Network, nodeCount int) ([]discover.NodeID, error)
|
|||
|
||||
for _, id := range ids {
|
||||
if err := net.Start(id); err != nil {
|
||||
log.Error("Error starting a node! %s", err)
|
||||
log.Error("Error starting a node!", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
log.Debug(fmt.Sprintf("node %v starting up", id))
|
||||
|
|
@ -185,7 +191,7 @@ func connectNodesInRing(net *Network, nodeCount int) ([]discover.NodeID, error)
|
|||
for i, id := range ids {
|
||||
peerID := ids[(i+1)%len(ids)]
|
||||
if err := net.Connect(id, peerID); err != nil {
|
||||
log.Error("Error connecting a node to a peer! %s", err)
|
||||
log.Error("Error connecting a node to a peer!", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue