mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
p2p: re-add check for self in checkDial
This commit is contained in:
parent
613ef8db02
commit
59556bdfee
3 changed files with 8 additions and 4 deletions
|
|
@ -357,6 +357,9 @@ func (d *dialScheduler) freeDialSlots() int {
|
||||||
|
|
||||||
// checkDial returns an error if node n should not be dialed.
|
// checkDial returns an error if node n should not be dialed.
|
||||||
func (d *dialScheduler) checkDial(n *enode.Node) error {
|
func (d *dialScheduler) checkDial(n *enode.Node) error {
|
||||||
|
if n.ID() == d.self {
|
||||||
|
return errSelf
|
||||||
|
}
|
||||||
if _, ok := d.dialing[n.ID()]; ok {
|
if _, ok := d.dialing[n.ID()]; ok {
|
||||||
return errAlreadyDialing
|
return errAlreadyDialing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,10 +250,10 @@ func TestDialSchedManyStaticNodes(t *testing.T) {
|
||||||
uintID(0xFFFF),
|
uintID(0xFFFF),
|
||||||
},
|
},
|
||||||
wantNewDials: []*enode.Node{
|
wantNewDials: []*enode.Node{
|
||||||
newNode(uintID(0x0321), "127.0.0.1:30303"),
|
newNode(uintID(0x0085), "127.0.0.1:30303"),
|
||||||
newNode(uintID(0x02E2), "127.0.0.1:30303"),
|
newNode(uintID(0x02dc), "127.0.0.1:30303"),
|
||||||
newNode(uintID(0x01E2), "127.0.0.1:30303"),
|
newNode(uintID(0x0285), "127.0.0.1:30303"),
|
||||||
newNode(uintID(0x03D5), "127.0.0.1:30303"),
|
newNode(uintID(0x00cb), "127.0.0.1:30303"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -596,6 +596,7 @@ func (srv *Server) setupDiscovery() error {
|
||||||
|
|
||||||
func (srv *Server) setupDialScheduler() {
|
func (srv *Server) setupDialScheduler() {
|
||||||
config := dialConfig{
|
config := dialConfig{
|
||||||
|
self: srv.localnode.ID(),
|
||||||
maxDialPeers: srv.maxDialedConns(),
|
maxDialPeers: srv.maxDialedConns(),
|
||||||
maxActiveDials: srv.MaxPendingPeers,
|
maxActiveDials: srv.MaxPendingPeers,
|
||||||
resolver: srv.ntab,
|
resolver: srv.ntab,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue