mirror of https://github.com/status-im/op-geth.git
p2p/discover: permit temporary bond failures for previously known nodes
This commit is contained in:
parent
6078aa08eb
commit
5076170f34
|
@ -324,6 +324,7 @@ func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16
|
||||||
fails = tab.db.findFails(id)
|
fails = tab.db.findFails(id)
|
||||||
}
|
}
|
||||||
// If the node is unknown (non-bonded) or failed (remotely unknown), bond from scratch
|
// If the node is unknown (non-bonded) or failed (remotely unknown), bond from scratch
|
||||||
|
var result error
|
||||||
if node == nil || fails > 0 {
|
if node == nil || fails > 0 {
|
||||||
glog.V(logger.Detail).Infof("Bonding %x: known=%v, fails=%v", id[:8], node != nil, fails)
|
glog.V(logger.Detail).Infof("Bonding %x: known=%v, fails=%v", id[:8], node != nil, fails)
|
||||||
|
|
||||||
|
@ -345,22 +346,24 @@ func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16
|
||||||
delete(tab.bonding, id)
|
delete(tab.bonding, id)
|
||||||
tab.bondmu.Unlock()
|
tab.bondmu.Unlock()
|
||||||
}
|
}
|
||||||
node = w.n
|
// Retrieve the bonding results
|
||||||
if w.err != nil {
|
result = w.err
|
||||||
return nil, w.err
|
if result == nil {
|
||||||
|
node = w.n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bonding succeeded, add to the table and reset previous findnode failures
|
// Even if bonding temporarily failed, give the node a chance
|
||||||
tab.mutex.Lock()
|
if node != nil {
|
||||||
defer tab.mutex.Unlock()
|
tab.mutex.Lock()
|
||||||
|
defer tab.mutex.Unlock()
|
||||||
|
|
||||||
b := tab.buckets[logdist(tab.self.sha, node.sha)]
|
b := tab.buckets[logdist(tab.self.sha, node.sha)]
|
||||||
if !b.bump(node) {
|
if !b.bump(node) {
|
||||||
tab.pingreplace(node, b)
|
tab.pingreplace(node, b)
|
||||||
|
}
|
||||||
|
tab.db.updateFindFails(id, 0)
|
||||||
}
|
}
|
||||||
tab.db.updateFindFails(id, 0)
|
return node, result
|
||||||
|
|
||||||
return node, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tab *Table) pingpong(w *bondproc, pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16) {
|
func (tab *Table) pingpong(w *bondproc, pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16) {
|
||||||
|
|
Loading…
Reference in New Issue