From 1f7f95d7182104e705a0735df456877764d1f562 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 10 Sep 2025 19:51:04 +0200 Subject: [PATCH] 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 --- p2p/discover/v5_udp.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/p2p/discover/v5_udp.go b/p2p/discover/v5_udp.go index 9679f5c61a..c13032e1af 100644 --- a/p2p/discover/v5_udp.go +++ b/p2p/discover/v5_udp.go @@ -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) }