From 08619220b4b0bfb6e87b78e6a3eacf67ad5a6061 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 18 Jul 2018 15:29:50 +0200 Subject: [PATCH] config/peer: make trickleTimeout configurable --- config.go | 3 +++ peer/peer.go | 10 +++++----- server.go | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 772c5ef8..f5d892a7 100644 --- a/config.go +++ b/config.go @@ -47,6 +47,7 @@ const ( defaultMaxRPCConcurrentReqs = 20 defaultDbType = "ffldb" defaultFreeTxRelayLimit = 15.0 + defaultTrickleTimeout = time.Second * 10 defaultBlockMinSize = 0 defaultBlockMaxSize = 750000 defaultBlockMinWeight = 0 @@ -140,6 +141,7 @@ type config struct { MinRelayTxFee float64 `long:"minrelaytxfee" description:"The minimum transaction fee in BTC/kB to be considered a non-zero fee."` FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"` NoRelayPriority bool `long:"norelaypriority" description:"Do not require free or low-fee transactions to have high priority for relaying"` + TrickleTimeout time.Duration `long:"trickletimeout" description:"Minimum time between attempts to send new inventory to a connected peer"` MaxOrphanTxs int `long:"maxorphantx" description:"Max number of orphan transactions to keep in memory"` Generate bool `long:"generate" description:"Generate (mine) bitcoins using the CPU"` MiningAddrs []string `long:"miningaddr" description:"Add the specified payment address to the list of addresses to use for generated blocks -- At least one address is required if the generate option is set"` @@ -415,6 +417,7 @@ func loadConfig() (*config, []string, error) { RPCCert: defaultRPCCertFile, MinRelayTxFee: mempool.DefaultMinRelayTxFee.ToBTC(), FreeTxRelayLimit: defaultFreeTxRelayLimit, + TrickleTimeout: defaultTrickleTimeout, BlockMinSize: defaultBlockMinSize, BlockMaxSize: defaultBlockMaxSize, BlockMinWeight: defaultBlockMinWeight, diff --git a/peer/peer.go b/peer/peer.go index 2fdf3e42..f0dd5706 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -64,10 +64,6 @@ const ( // stalling. The deadlines are adjusted for callback running times and // only checked on each stall tick interval. stallResponseTimeout = 30 * time.Second - - // trickleTimeout is the duration of the ticker which trickles down the - // inventory to a peer. - trickleTimeout = 10 * time.Second ) var ( @@ -268,6 +264,10 @@ type Config struct { // Listeners houses callback functions to be invoked on receiving peer // messages. Listeners MessageListeners + + // TrickleTimeout is the duration of the ticker which trickles down the + // inventory to a peer. + TrickleTimeout time.Duration } // minUint32 is a helper function to return the minimum of two uint32s. @@ -1693,7 +1693,7 @@ out: func (p *Peer) queueHandler() { pendingMsgs := list.New() invSendQueue := list.New() - trickleTicker := time.NewTicker(trickleTimeout) + trickleTicker := time.NewTicker(p.cfg.TrickleTimeout) defer trickleTicker.Stop() // We keep the waiting flag so that we know if we have a message queued diff --git a/server.go b/server.go index e41f27e5..8288d246 100644 --- a/server.go +++ b/server.go @@ -1947,6 +1947,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config { Services: sp.server.services, DisableRelayTx: cfg.BlocksOnly, ProtocolVersion: peer.MaxProtocolVersion, + TrickleTimeout: cfg.TrickleTimeout, } }