mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 06:53:46 +00:00
fix:add enr should add node immediately
Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
parent
f8c05e17eb
commit
af02291ad4
3 changed files with 4 additions and 6 deletions
|
|
@ -102,7 +102,8 @@ func (d *DiscV5API) AddEnr(enr string) (bool, error) {
|
||||||
return false, err
|
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
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,8 @@ func (p *PortalProtocol) RoutingTableInfo() [][]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PortalProtocol) AddEnr(n *enode.Node) {
|
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()
|
id := n.ID().String()
|
||||||
p.radiusCache.Set([]byte(id), MaxDistance)
|
p.radiusCache.Set([]byte(id), MaxDistance)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -268,10 +268,6 @@ func TestPortalWireProtocol(t *testing.T) {
|
||||||
|
|
||||||
time.Sleep(12 * time.Second)
|
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 {
|
slices.ContainsFunc(node1.table.NodeList(), func(n *enode.Node) bool {
|
||||||
return n.ID() == node2.localNode.Node().ID()
|
return n.ID() == node2.localNode.Node().ID()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue