set node state to JOIN once received PONG message

Signed-off-by: Leo Chen <leo@harmony.one>
pull/89/head
Leo Chen 6 years ago
parent 8ddb055cd6
commit b722e495d3
  1. 4
      node/node.go
  2. 1
      node/node_handler.go

@ -264,7 +264,6 @@ func (node *Node) AddPeers(peers []p2p.Peer) int {
count++
}
}
node.log.Info("Added", "# of peers", count)
if count > 0 {
c := node.Consensus.AddPeers(peers)
@ -275,7 +274,7 @@ func (node *Node) AddPeers(peers []p2p.Peer) int {
func (node *Node) JoinShard(leader p2p.Peer) {
// try to join the shard, with 10 minutes time-out
backoff := p2p.NewExpBackoff(500*time.Millisecond, 10*time.Minute, 2)
backoff := p2p.NewExpBackoff(1*time.Second, 10*time.Minute, 2)
for node.State == WAIT {
backoff.Sleep()
@ -285,5 +284,4 @@ func (node *Node) JoinShard(leader p2p.Peer) {
p2p.SendMessage(leader, buffer)
node.log.Debug("Sent ping message")
}
}

@ -548,6 +548,7 @@ func (node *Node) pongMessageHandler(msgPayload []byte) {
return
}
node.log.Info("Pong", "Msg", pong)
node.State = JOIN
peers := make([]p2p.Peer, 0)

Loading…
Cancel
Save