mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-01 01:23:46 +00:00
fix:add lock in addenr
Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
parent
98047b22a3
commit
792b4746b8
2 changed files with 4 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue