mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
p2p/discover: fix two bugs in lookup iterator
The lookup would add self into the replyBuffer if returned by another node. Avoid doing that by marking self as seen. With the changed initialization behavior of lookup, the lookupIterator needs to yield the buffer right after creation. This fixes the smallNetConvergence test, where all results are straight out of the local table.
This commit is contained in:
parent
cf0503da7c
commit
3946708935
1 changed files with 5 additions and 0 deletions
|
|
@ -53,6 +53,7 @@ func newLookup(ctx context.Context, tab *Table, target enode.ID, q queryFunc) *l
|
|||
// Don't query further if we hit ourself.
|
||||
// Unlikely to happen often in practice.
|
||||
it.asked[tab.self().ID()] = true
|
||||
it.seen[tab.self().ID()] = true
|
||||
|
||||
// Initialize the lookup with nodes from table.
|
||||
closest := it.tab.findnodeByID(it.result.target, bucketSize, false)
|
||||
|
|
@ -186,8 +187,12 @@ func (it *lookupIterator) Next() bool {
|
|||
// is in a degraded state, and we need to wait for it to fill again.
|
||||
it.lookupFailed(it.lookup.tab)
|
||||
}
|
||||
// Otherwise, yield the initial nodes from the iterator before advancing
|
||||
// the lookup.
|
||||
it.buffer = it.lookup.replyBuffer
|
||||
continue
|
||||
}
|
||||
|
||||
newNodes := it.lookup.advance()
|
||||
it.buffer = it.lookup.replyBuffer
|
||||
if !newNodes {
|
||||
|
|
|
|||
Loading…
Reference in a new issue