Fix ping bootstrap

pull/1936/head
Rongjian Lan 5 years ago
parent 8c7dca4cc6
commit 24962022be
  1. 9
      api/service/discovery/service.go

@ -74,7 +74,6 @@ func (s *Service) Run() {
}
func (s *Service) contactP2pPeers() {
pingInterval := 1
nodeConfig := nodeconfig.GetShardConfig(s.config.ShardID)
// Don't send ping message for Explorer Node
@ -86,6 +85,8 @@ func (s *Service) contactP2pPeers() {
msgBuf := host.ConstructP2pMessage(byte(0), pingMsg.ConstructPingMessage())
s.sentPingMessage(s.config.ShardGroupID, msgBuf)
pingInterval := 5
initialFlatRetries := 20 // no expotential backoff for 20 times.
for {
select {
case peer, ok := <-s.peerChan:
@ -111,7 +112,11 @@ func (s *Service) contactP2pPeers() {
if pingInterval >= 3600 {
pingInterval = 3600
} else {
pingInterval *= 2
if initialFlatRetries > 0 {
initialFlatRetries--
} else {
pingInterval *= 2
}
}
time.Sleep(time.Duration(pingInterval) * time.Second)
}

Loading…
Cancel
Save