Browse Source

defaultSeedDisconnectWaitPeriod should be at least as long as we expect

it to take for a peer to become MarkGood

Refs #1130
pull/1344/merge
Anton Kaliaev 7 years ago
parent
commit
8e699c2bfd
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      p2p/pex/pex_reactor.go

+ 12
- 11
p2p/pex/pex_reactor.go View File

@ -30,15 +30,17 @@ const (
defaultMinNumOutboundPeers = 10
// Seed/Crawler constants
// TODO:
// We want seeds to only advertise good peers.
// Peers are marked by external mechanisms.
// We need a config value that can be set to be
// on the order of how long it would take before a good
// peer is marked good.
defaultSeedDisconnectWaitPeriod = 2 * time.Minute // disconnect after this
defaultCrawlPeerInterval = 2 * time.Minute // dont redial for this. TODO: back-off
defaultCrawlPeersPeriod = 30 * time.Second // check some peers every this
// We want seeds to only advertise good peers. Therefore they should wait at
// least as long as we expect it to take for a peer to become good before
// disconnecting.
// see consensus/reactor.go: blocksToContributeToBecomeGoodPeer
// 10000 blocks assuming 1s blocks ~ 2.7 hours.
defaultSeedDisconnectWaitPeriod = 3 * time.Hour
defaultCrawlPeerInterval = 2 * time.Minute // don't redial for this. TODO: back-off. what for?
defaultCrawlPeersPeriod = 30 * time.Second // check some peers every this
maxAttemptsToDial = 16 // ~ 35h in total (last attempt - 18h)
)
@ -578,8 +580,7 @@ func (r *PEXReactor) crawlPeers() {
// attemptDisconnects checks if we've been with each peer long enough to disconnect
func (r *PEXReactor) attemptDisconnects() {
for _, peer := range r.Switch.Peers().List() {
status := peer.Status()
if status.Duration < defaultSeedDisconnectWaitPeriod {
if peer.Status().Duration < defaultSeedDisconnectWaitPeriod {
continue
}
if peer.IsPersistent() {


Loading…
Cancel
Save