peer/peer: switch TrickleTimeout -> TrickleInterval

This commit is contained in:
Conner Fromknecht 2018-08-23 22:48:28 -07:00
parent 7a657ffa2e
commit 602bced5f5
No known key found for this signature in database
GPG key ID: E7D737B67FA592C7

View file

@ -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,