Skip to content

Commit

Permalink
peer: Offset ping interval from idle timeout.
Browse files Browse the repository at this point in the history
This modifies the ping interval to be defined in terms of the default
idle timeout such that it is shorter and relatively prime to it to help
prevent undesirable disconnects in higher latency scenarios.
  • Loading branch information
davecgh committed Nov 10, 2021
1 parent 1487c03 commit 3a458e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ const (
// inventory cache.
maxKnownInventory = 1000

// pingInterval is the interval of time to wait in between sending ping
// messages.
pingInterval = 2 * time.Minute

// negotiateTimeout is the duration of inactivity before we timeout a
// peer that hasn't completed the initial version negotiation.
negotiateTimeout = 30 * time.Second
Expand All @@ -66,6 +62,10 @@ const (
// timed out when a peer is created with the idle timeout configuration
// option set to 0.
defaultIdleTimeout = 120 * time.Second

// pingInterval is the interval of time to wait in between sending ping
// messages.
pingInterval = defaultIdleTimeout - 13*time.Second
)

var (
Expand Down

0 comments on commit 3a458e1

Please sign in to comment.