peer/peer: switch TrickleTimeout -> TrickleInterval
This commit is contained in:
parent
7a657ffa2e
commit
602bced5f5
1 changed files with 12 additions and 3 deletions
15
peer/peer.go
15
peer/peer.go
|
@ -30,6 +30,10 @@ const (
|
||||||
// MaxProtocolVersion is the max protocol version the peer supports.
|
// MaxProtocolVersion is the max protocol version the peer supports.
|
||||||
MaxProtocolVersion = wire.FeeFilterVersion
|
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
|
// minAcceptableProtocolVersion is the lowest protocol version that a
|
||||||
// connected peer may support.
|
// connected peer may support.
|
||||||
minAcceptableProtocolVersion = wire.MultipleAddressVersion
|
minAcceptableProtocolVersion = wire.MultipleAddressVersion
|
||||||
|
@ -266,9 +270,9 @@ type Config struct {
|
||||||
// messages.
|
// messages.
|
||||||
Listeners MessageListeners
|
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.
|
// inventory to a peer.
|
||||||
TrickleTimeout time.Duration
|
TrickleInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// minUint32 is a helper function to return the minimum of two uint32s.
|
// minUint32 is a helper function to return the minimum of two uint32s.
|
||||||
|
@ -1549,7 +1553,7 @@ out:
|
||||||
func (p *Peer) queueHandler() {
|
func (p *Peer) queueHandler() {
|
||||||
pendingMsgs := list.New()
|
pendingMsgs := list.New()
|
||||||
invSendQueue := list.New()
|
invSendQueue := list.New()
|
||||||
trickleTicker := time.NewTicker(p.cfg.TrickleTimeout)
|
trickleTicker := time.NewTicker(p.cfg.TrickleInterval)
|
||||||
defer trickleTicker.Stop()
|
defer trickleTicker.Stop()
|
||||||
|
|
||||||
// We keep the waiting flag so that we know if we have a message queued
|
// 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
|
cfg.ChainParams = &chaincfg.TestNet3Params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the trickle interval if a non-positive value is specified.
|
||||||
|
if cfg.TrickleInterval <= 0 {
|
||||||
|
cfg.TrickleInterval = DefaultTrickleInterval
|
||||||
|
}
|
||||||
|
|
||||||
p := Peer{
|
p := Peer{
|
||||||
inbound: inbound,
|
inbound: inbound,
|
||||||
wireEncoding: wire.BaseEncoding,
|
wireEncoding: wire.BaseEncoding,
|
||||||
|
|
Loading…
Reference in a new issue