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