mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
p2p/discover: use maxFindnodeFailures constant in ensureBond
This commit is contained in:
parent
aa470f8905
commit
4bdf1a4b99
2 changed files with 8 additions and 9 deletions
|
|
@ -53,13 +53,12 @@ const (
|
||||||
bucketIPLimit, bucketSubnet = 2, 24 // at most 2 addresses from the same /24
|
bucketIPLimit, bucketSubnet = 2, 24 // at most 2 addresses from the same /24
|
||||||
tableIPLimit, tableSubnet = 10, 24
|
tableIPLimit, tableSubnet = 10, 24
|
||||||
|
|
||||||
maxFindnodeFailures = 5 // Nodes exceeding this limit are dropped
|
refreshInterval = 30 * time.Minute
|
||||||
refreshInterval = 30 * time.Minute
|
revalidateInterval = 10 * time.Second
|
||||||
revalidateInterval = 10 * time.Second
|
copyNodesInterval = 30 * time.Second
|
||||||
copyNodesInterval = 30 * time.Second
|
seedMinTableTime = 5 * time.Minute
|
||||||
seedMinTableTime = 5 * time.Minute
|
seedCount = 30
|
||||||
seedCount = 30
|
seedMaxAge = 5 * 24 * time.Hour
|
||||||
seedMaxAge = 5 * 24 * time.Hour
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Table is the 'node table', a Kademlia-like index of neighbor nodes. The table keeps
|
// Table is the 'node table', a Kademlia-like index of neighbor nodes. The table keeps
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@ var (
|
||||||
errClosed = errors.New("socket closed")
|
errClosed = errors.New("socket closed")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Timeouts
|
|
||||||
const (
|
const (
|
||||||
respTimeout = 500 * time.Millisecond
|
respTimeout = 500 * time.Millisecond
|
||||||
expiration = 20 * time.Second
|
expiration = 20 * time.Second
|
||||||
bondExpiration = 24 * time.Hour
|
bondExpiration = 24 * time.Hour
|
||||||
|
|
||||||
|
maxFindnodeFailures = 5 // nodes exceeding this limit are dropped
|
||||||
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
|
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
|
||||||
ntpWarningCooldown = 10 * time.Minute // Minimum amount of time to pass before repeating NTP warning
|
ntpWarningCooldown = 10 * time.Minute // Minimum amount of time to pass before repeating NTP warning
|
||||||
driftThreshold = 10 * time.Second // Allowed clock drift before warning user
|
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.
|
// This ensures there is a valid endpoint proof on the remote end.
|
||||||
func (t *UDPv4) ensureBond(toid enode.ID, toaddr *net.UDPAddr) {
|
func (t *UDPv4) ensureBond(toid enode.ID, toaddr *net.UDPAddr) {
|
||||||
tooOld := time.Since(t.db.LastPingReceived(toid, toaddr.IP)) > bondExpiration
|
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 := t.sendPing(toid, toaddr, nil)
|
||||||
<-rm.errc
|
<-rm.errc
|
||||||
// Wait for them to ping back and process our pong.
|
// Wait for them to ping back and process our pong.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue