config/peer: make trickleTimeout configurable

This commit is contained in:
Johan T. Halseth 2018-07-18 15:29:50 +02:00
parent 9a2f952402
commit 08619220b4
No known key found for this signature in database
GPG key ID: 15BAADA29DA20D26
3 changed files with 9 additions and 5 deletions

View file

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

View file

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

View file

@ -1947,6 +1947,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config {
Services: sp.server.services,
DisableRelayTx: cfg.BlocksOnly,
ProtocolVersion: peer.MaxProtocolVersion,
TrickleTimeout: cfg.TrickleTimeout,
}
}