mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
p2p/discover: remove delay from iterator init
Refresh is doing some lookups and thus it could block for some time. We do not want the initialized of an iterator to block. If there is something blocking, it should happen when calling Next. Here, next will start a lookup, which will wait if needed (no nodes), making sure the iterator's Next is not creating a busy loop. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
25cce4dfe4
commit
2a21e3c06f
1 changed files with 0 additions and 6 deletions
|
|
@ -328,12 +328,6 @@ func (t *UDPv5) TalkRequestToID(id enode.ID, addr netip.AddrPort, protocol strin
|
|||
|
||||
// RandomNodes returns an iterator that finds random nodes in the DHT.
|
||||
func (t *UDPv5) RandomNodes() enode.Iterator {
|
||||
if t.tab.len() == 0 {
|
||||
// All nodes were dropped, refresh. The very first query will hit this
|
||||
// case and run the bootstrapping logic.
|
||||
<-t.tab.refresh()
|
||||
}
|
||||
|
||||
return newLookupIterator(t.closeCtx, t.newRandomLookup)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue