diff --git a/config.go b/config.go index 7124fe92908..a18750efae6 100644 --- a/config.go +++ b/config.go @@ -135,6 +135,7 @@ type config struct { NoRelayPriority bool `long:"norelaypriority" description:"Do not require free or low-fee transactions to have high priority for relaying"` NoWinService bool `long:"nowinservice" description:"Do not start as a background service on Windows -- NOTE: This flag only works on the command line, not in the config file"` DisableRPC bool `long:"norpc" description:"Disable built-in RPC server -- NOTE: The RPC server is disabled by default if no rpcuser/rpcpass or rpclimituser/rpclimitpass is specified"` + DisableStallHandler bool `long:"nostalldetect" description:"Disables the stall handler system for each peer, useful in simnet/regtest integration tests frameworks"` DisableTLS bool `long:"notls" description:"Disable TLS for the RPC server -- NOTE: This is only allowed if the RPC server is bound to localhost"` OnionProxy string `long:"onion" description:"Connect to tor hidden services via SOCKS5 proxy (eg. 127.0.0.1:9050)"` OnionProxyPass string `long:"onionpass" default-mask:"-" description:"Password for onion proxy server"` diff --git a/peer/peer.go b/peer/peer.go index 92ac3d27e84..cc0402fda4a 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -276,6 +276,13 @@ type Config struct { // connection detecting and disconnect logic since they intentionally // do so for testing purposes. AllowSelfConns bool + + // DisableStallHandler if true, then the stall handler that attempts to + // disconnect from peers that appear to be taking too long to respond + // to requests won't be activated. This can be useful in certain simnet + // scenarios where the stall behaver isn't important to the system + // under test. + DisableStallHandler bool } // minUint32 is a helper function to return the minimum of two uint32s. @@ -2152,9 +2159,14 @@ func (p *Peer) start() error { } log.Debugf("Connected to %s", p.Addr()) + // If the stall handler is disabled, then we don't need to launch the + // goroutine that will attempt to boot peers that seem to be lagging. + if !p.cfg.DisableStallHandler { + go p.stallHandler() + } + // The protocol has been negotiated successfully so start processing input // and output messages. - go p.stallHandler() go p.inHandler() go p.queueHandler() go p.outHandler() diff --git a/server.go b/server.go index ba7932a1a48..746c48dde36 100644 --- a/server.go +++ b/server.go @@ -2054,17 +2054,18 @@ func newPeerConfig(sp *serverPeer) *peer.Config { // other implementations' alert messages, we will not relay theirs. OnAlert: nil, }, - NewestBlock: sp.newestBlock, - HostToNetAddress: sp.server.addrManager.HostToNetAddress, - Proxy: cfg.Proxy, - UserAgentName: userAgentName, - UserAgentVersion: userAgentVersion, - UserAgentComments: cfg.UserAgentComments, - ChainParams: sp.server.chainParams, - Services: sp.server.services, - DisableRelayTx: cfg.BlocksOnly, - ProtocolVersion: peer.MaxProtocolVersion, - TrickleInterval: cfg.TrickleInterval, + NewestBlock: sp.newestBlock, + HostToNetAddress: sp.server.addrManager.HostToNetAddress, + Proxy: cfg.Proxy, + UserAgentName: userAgentName, + UserAgentVersion: userAgentVersion, + UserAgentComments: cfg.UserAgentComments, + ChainParams: sp.server.chainParams, + Services: sp.server.services, + DisableRelayTx: cfg.BlocksOnly, + ProtocolVersion: peer.MaxProtocolVersion, + TrickleInterval: cfg.TrickleInterval, + DisableStallHandler: cfg.DisableStallHandler, } }