HAR-65: use constants for backoff

Signed-off-by: Leo Chen <leo@harmony.one>
pull/116/head
Leo Chen 6 years ago
parent 0407dc559b
commit 62f1f60924
  1. 4
      node/node.go

@ -50,6 +50,8 @@ const (
const (
// TimeToSleepForSyncing is the time waiting for node transformed into NodeDoingConsensus
TimeToSleepForSyncing = time.Second * 30
waitBeforeJoinShard = time.Second * 3
timeOutToJoinShard = time.Minute * 10
)
// NetworkNode ...
@ -349,7 +351,7 @@ func (node *Node) AddPeers(peers []*p2p.Peer) int {
// JoinShard helps a new node to join a shard.
func (node *Node) JoinShard(leader p2p.Peer) {
// try to join the shard, with 10 minutes time-out
backoff := p2p.NewExpBackoff(3*time.Second, 10*time.Minute, 2)
backoff := p2p.NewExpBackoff(waitBeforeJoinShard, timeOutToJoinShard, 2)
for node.State == NodeWaitToJoin {
backoff.Sleep()

Loading…
Cancel
Save