Skip to content

Commit 1f7f95d

Browse files
authored
p2p/discover: remove delay from discv5 RandomNodes (#32517)
Refresh is doing some lookups and thus it could block for some time. We do not want the initializer 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 <[email protected]>
1 parent b708feb commit 1f7f95d

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

p2p/discover/v5_udp.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,6 @@ func (t *UDPv5) TalkRequestToID(id enode.ID, addr netip.AddrPort, protocol strin
328328

329329
// RandomNodes returns an iterator that finds random nodes in the DHT.
330330
func (t *UDPv5) RandomNodes() enode.Iterator {
331-
if t.tab.len() == 0 {
332-
// All nodes were dropped, refresh. The very first query will hit this
333-
// case and run the bootstrapping logic.
334-
<-t.tab.refresh()
335-
}
336-
337331
return newLookupIterator(t.closeCtx, t.newRandomLookup)
338332
}
339333

0 commit comments

Comments
 (0)