p2p/discover: fix timeout on refresh if no bootnodes

If we have no nodes to add in a refresh, and the table is empty,
it is useless to do lookups.

This was triggering a 3 second wait for a timeout in the
initialization code, making some hive tests fail.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-08-28 23:42:47 +02:00
parent 25cce4dfe4
commit fb4dff44dc
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -428,6 +428,12 @@ func (tab *Table) doRefresh(done chan struct{}) {
// (hopefully) still alive.
tab.loadSeedNodes()
// If the table is empty, we cannot perform any lookups.
if tab.len() == 0 {
log.Debug("doRefresh called, but no nodes to start from")
return
}
// Run self lookup to discover new neighbor nodes.
tab.net.lookupSelf()