diff --git a/p2p/discover/api.go b/p2p/discover/api.go index d39702d9f5..1e06068404 100644 --- a/p2p/discover/api.go +++ b/p2p/discover/api.go @@ -103,6 +103,8 @@ func (d *DiscV5API) AddEnr(enr string) (bool, error) { } // immediately add the node to the routing table + d.DiscV5.tab.mutex.Lock() + defer d.DiscV5.tab.mutex.Unlock() 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 baef3b17fe..670a2f48fa 100644 --- a/p2p/discover/portal_protocol.go +++ b/p2p/discover/portal_protocol.go @@ -288,6 +288,8 @@ func (p *PortalProtocol) RoutingTableInfo() [][]string { func (p *PortalProtocol) AddEnr(n *enode.Node) { // immediately add the node to the routing table + p.table.mutex.Lock() + defer p.table.mutex.Unlock() p.table.handleAddNode(addNodeOp{node: n, isInbound: false, forceSetLive: true}) id := n.ID().String() p.radiusCache.Set([]byte(id), MaxDistance)