mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
p2p/discover: reduce findnode failure counter on success
This commit is contained in:
parent
9fd429fa3f
commit
ccb1e57ede
1 changed files with 7 additions and 4 deletions
|
|
@ -316,17 +316,20 @@ func (tab *Table) lookup(targetID NodeID, refreshIfEmpty bool) []*Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tab *Table) findnode(n *Node, targetID NodeID, reply chan<- []*Node) {
|
func (tab *Table) findnode(n *Node, targetID NodeID, reply chan<- []*Node) {
|
||||||
|
fails := tab.db.findFails(n.ID)
|
||||||
r, err := tab.net.findnode(n.ID, n.addr(), targetID)
|
r, err := tab.net.findnode(n.ID, n.addr(), targetID)
|
||||||
if err != nil {
|
if err != nil || len(r) == 0 {
|
||||||
// Bump the failure counter to detect and evacuate non-bonded entries
|
fails++
|
||||||
fails := tab.db.findFails(n.ID) + 1
|
|
||||||
tab.db.updateFindFails(n.ID, fails)
|
tab.db.updateFindFails(n.ID, fails)
|
||||||
log.Trace("Bumping findnode failure counter", "id", n.ID, "failcount", fails)
|
log.Trace("Findnode failed", "id", n.ID, "failcount", fails, "err", err)
|
||||||
if fails >= maxFindnodeFailures {
|
if fails >= maxFindnodeFailures {
|
||||||
log.Trace("Too many findnode failures, dropping", "id", n.ID, "failcount", fails)
|
log.Trace("Too many findnode failures, dropping", "id", n.ID, "failcount", fails)
|
||||||
tab.delete(n)
|
tab.delete(n)
|
||||||
}
|
}
|
||||||
|
} else if fails > 0 {
|
||||||
|
tab.db.updateFindFails(n.ID, fails-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab as many nodes as possible if we're in the init phase.
|
// Grab as many nodes as possible if we're in the init phase.
|
||||||
if !tab.isInitDone() {
|
if !tab.isInitDone() {
|
||||||
for _, n := range r {
|
for _, n := range r {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue