defaultSeedDisconnectWaitPeriod should be at least as long as we expect

it to take for a peer to become MarkGood

Refs #1130
This commit is contained in:
Anton Kaliaev 2018-03-24 17:04:32 +01:00
parent 7689c15413
commit 8e699c2bfd

View File

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