diff --git a/p2p/discover/api.go b/p2p/discover/api.go index a972c2e03719..19af1647f385 100644 --- a/p2p/discover/api.go +++ b/p2p/discover/api.go @@ -102,7 +102,8 @@ func (d *DiscV5API) AddEnr(enr string) (bool, error) { return false, err } - d.DiscV5.tab.addFoundNode(n, true) + // immediately add the node to the routing table + d.DiscV5.tab.handleAddNode(addNodeOp{node: n, isInbound: false, forceSetLive: true}) return true, nil } diff --git a/p2p/discover/portal_protocol.go b/p2p/discover/portal_protocol.go index 9445b504694f..baef3b17fe09 100644 --- a/p2p/discover/portal_protocol.go +++ b/p2p/discover/portal_protocol.go @@ -287,7 +287,8 @@ func (p *PortalProtocol) RoutingTableInfo() [][]string { } func (p *PortalProtocol) AddEnr(n *enode.Node) { - p.table.addFoundNode(n, true) + // immediately add the node to the routing table + p.table.handleAddNode(addNodeOp{node: n, isInbound: false, forceSetLive: true}) id := n.ID().String() p.radiusCache.Set([]byte(id), MaxDistance) } diff --git a/p2p/discover/portal_protocol_test.go b/p2p/discover/portal_protocol_test.go index 605cfa3c0a6e..26c452d2e7fa 100644 --- a/p2p/discover/portal_protocol_test.go +++ b/p2p/discover/portal_protocol_test.go @@ -268,10 +268,6 @@ func TestPortalWireProtocol(t *testing.T) { time.Sleep(12 * time.Second) - assert.Equal(t, 2, len(node1.table.NodeList())) - assert.Equal(t, 2, len(node2.table.NodeList())) - assert.Equal(t, 2, len(node3.table.NodeList())) - slices.ContainsFunc(node1.table.NodeList(), func(n *enode.Node) bool { return n.ID() == node2.localNode.Node().ID() })