This commit is contained in:
cui 2026-02-25 21:56:45 -08:00 committed by GitHub
commit 8501c8d819
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -254,11 +254,30 @@ func (tab *Table) findnodeByID(target enode.ID, nresults int, preferLive bool) *
// is O(tab.len() * nresults).
nodes := &nodesByDistance{target: target}
liveNodes := &nodesByDistance{target: target}
for _, b := range &tab.buckets {
for _, n := range b.entries {
nodes.push(n.Node, nresults)
if preferLive && n.isValidatedLive {
liveNodes.push(n.Node, nresults)
var liveNodesFound = false
if preferLive {
outer:
for _, b := range &tab.buckets {
for _, n := range b.entries {
if n.isValidatedLive {
liveNodesFound = true
break outer
}
}
}
}
if liveNodesFound {
for _, b := range &tab.buckets {
for _, n := range b.entries {
if n.isValidatedLive {
liveNodes.push(n.Node, nresults)
}
}
}
} else {
for _, b := range &tab.buckets {
for _, n := range b.entries {
nodes.push(n.Node, nresults)
}
}
}