diff --git a/peer/peer.go b/peer/peer.go index e96d2df9..55f607ca 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -60,6 +60,11 @@ const ( // trickleTimeout is the duration of the ticker which trickles down the // inventory to a peer. trickleTimeout = 500 * time.Millisecond + + // defaultIdleTimeout is the default duration of inactivity before a peer is + // timed out when a peer is created with the idle timeout configuration + // option set to 0. + defaultIdleTimeout = 120 * time.Second ) var ( @@ -2072,6 +2077,11 @@ func newPeerBase(cfgOrig *Config, inbound bool) *Peer { cfg.Net = wire.TestNet3 } + // Set a default idle timeout if the caller did not specify one. + if cfg.IdleTimeout == 0 { + cfg.IdleTimeout = defaultIdleTimeout + } + p := Peer{ inbound: inbound, knownInventory: lru.NewCache(maxKnownInventory),