From 602bced5f580438f6c5915208d966c63e34b8988 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 23 Aug 2018 22:48:28 -0700 Subject: [PATCH] peer/peer: switch TrickleTimeout -> TrickleInterval --- peer/peer.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/peer/peer.go b/peer/peer.go index 04332aa4..4fa77cf7 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -30,6 +30,10 @@ const ( // MaxProtocolVersion is the max protocol version the peer supports. MaxProtocolVersion = wire.FeeFilterVersion + // DefaultTrickleInterval is the min time between attempts to send an + // inv message to a peer. + DefaultTrickleInterval = 10 * time.Second + // minAcceptableProtocolVersion is the lowest protocol version that a // connected peer may support. minAcceptableProtocolVersion = wire.MultipleAddressVersion @@ -266,9 +270,9 @@ type Config struct { // messages. Listeners MessageListeners - // TrickleTimeout is the duration of the ticker which trickles down the + // TrickleInterval is the duration of the ticker which trickles down the // inventory to a peer. - TrickleTimeout time.Duration + TrickleInterval time.Duration } // minUint32 is a helper function to return the minimum of two uint32s. @@ -1549,7 +1553,7 @@ out: func (p *Peer) queueHandler() { pendingMsgs := list.New() invSendQueue := list.New() - trickleTicker := time.NewTicker(p.cfg.TrickleTimeout) + trickleTicker := time.NewTicker(p.cfg.TrickleInterval) defer trickleTicker.Stop() // We keep the waiting flag so that we know if we have a message queued @@ -2173,6 +2177,11 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer { cfg.ChainParams = &chaincfg.TestNet3Params } + // Set the trickle interval if a non-positive value is specified. + if cfg.TrickleInterval <= 0 { + cfg.TrickleInterval = DefaultTrickleInterval + } + p := Peer{ inbound: inbound, wireEncoding: wire.BaseEncoding,