|
|
|
@ -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) |
|
|
|
|
} |
|
|
|
|