From e8ac37223fae22eef27c178a25bf2beed28280e0 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 31 May 2022 20:07:25 +0200 Subject: [PATCH] pex: align max address thresholds (#8657) --- internal/p2p/pex/params.go | 2 +- internal/p2p/pex/pex_reactor.go | 8 +------- internal/p2p/pex/reactor.go | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/internal/p2p/pex/params.go b/internal/p2p/pex/params.go index 29b4d45ab..67e96724b 100644 --- a/internal/p2p/pex/params.go +++ b/internal/p2p/pex/params.go @@ -51,5 +51,5 @@ const ( // max addresses returned by GetSelection // NOTE: this must match "maxMsgSize" - maxGetSelection = 250 + maxGetSelection = 100 ) diff --git a/internal/p2p/pex/pex_reactor.go b/internal/p2p/pex/pex_reactor.go index 9eb58c054..0e9e4135b 100644 --- a/internal/p2p/pex/pex_reactor.go +++ b/internal/p2p/pex/pex_reactor.go @@ -102,12 +102,6 @@ type Reactor struct { crawlPeerInfos map[types.NodeID]crawlPeerInfo } -func (r *Reactor) minReceiveRequestInterval() time.Duration { - // NOTE: must be less than ensurePeersPeriod, otherwise we'll request - // peers too quickly from others and they'll think we're bad! - return r.ensurePeersPeriod / 3 -} - // ReactorConfig holds reactor specific configuration data. type ReactorConfig struct { // Seed/Crawler mode @@ -331,7 +325,7 @@ func (r *Reactor) receiveRequest(src Peer) error { } now := time.Now() - minInterval := r.minReceiveRequestInterval() + minInterval := minReceiveRequestInterval if now.Sub(lastReceived) < minInterval { return fmt.Errorf( "peer (%v) sent next PEX request too soon. lastReceived: %v, now: %v, minInterval: %v. Disconnecting", diff --git a/internal/p2p/pex/reactor.go b/internal/p2p/pex/reactor.go index 570832384..eadaee5cc 100644 --- a/internal/p2p/pex/reactor.go +++ b/internal/p2p/pex/reactor.go @@ -24,7 +24,7 @@ var ( // See https://github.com/tendermint/tendermint/issues/6371 const ( // the minimum time one peer can send another request to the same peer - minReceiveRequestInterval = 100 * time.Millisecond + minReceiveRequestInterval = 200 * time.Millisecond // the maximum amount of addresses that can be included in a response maxAddresses uint16 = 100