From 4bdf1a4b99814d1a499357c29a52433f3aa76f9d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 14 May 2019 08:09:16 -0400 Subject: [PATCH] p2p/discover: use maxFindnodeFailures constant in ensureBond --- p2p/discover/table.go | 13 ++++++------- p2p/discover/v4_udp.go | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 5ea5a358d2..c4e5df032f 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -53,13 +53,12 @@ const ( bucketIPLimit, bucketSubnet = 2, 24 // at most 2 addresses from the same /24 tableIPLimit, tableSubnet = 10, 24 - maxFindnodeFailures = 5 // Nodes exceeding this limit are dropped - refreshInterval = 30 * time.Minute - revalidateInterval = 10 * time.Second - copyNodesInterval = 30 * time.Second - seedMinTableTime = 5 * time.Minute - seedCount = 30 - seedMaxAge = 5 * 24 * time.Hour + refreshInterval = 30 * time.Minute + revalidateInterval = 10 * time.Second + copyNodesInterval = 30 * time.Second + seedMinTableTime = 5 * time.Minute + seedCount = 30 + seedMaxAge = 5 * 24 * time.Hour ) // Table is the 'node table', a Kademlia-like index of neighbor nodes. The table keeps diff --git a/p2p/discover/v4_udp.go b/p2p/discover/v4_udp.go index 49204b9664..314b497db2 100644 --- a/p2p/discover/v4_udp.go +++ b/p2p/discover/v4_udp.go @@ -48,12 +48,12 @@ var ( errClosed = errors.New("socket closed") ) -// Timeouts const ( respTimeout = 500 * time.Millisecond expiration = 20 * time.Second bondExpiration = 24 * time.Hour + maxFindnodeFailures = 5 // nodes exceeding this limit are dropped ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP ntpWarningCooldown = 10 * time.Minute // Minimum amount of time to pass before repeating NTP warning driftThreshold = 10 * time.Second // Allowed clock drift before warning user @@ -840,7 +840,7 @@ func (t *UDPv4) checkBond(id enode.ID, ip net.IP) bool { // This ensures there is a valid endpoint proof on the remote end. func (t *UDPv4) ensureBond(toid enode.ID, toaddr *net.UDPAddr) { tooOld := time.Since(t.db.LastPingReceived(toid, toaddr.IP)) > bondExpiration - if tooOld || t.db.FindFails(toid, toaddr.IP) > 5 { + if tooOld || t.db.FindFails(toid, toaddr.IP) > maxFindnodeFailures { rm := t.sendPing(toid, toaddr, nil) <-rm.errc // Wait for them to ping back and process our pong.