p2p: re-add check for self in checkDial

This commit is contained in:
Felix Lange 2020-01-24 21:07:55 +01:00
parent 613ef8db02
commit 59556bdfee
3 changed files with 8 additions and 4 deletions

View file

@ -357,6 +357,9 @@ func (d *dialScheduler) freeDialSlots() int {
// checkDial returns an error if node n should not be dialed.
func (d *dialScheduler) checkDial(n *enode.Node) error {
if n.ID() == d.self {
return errSelf
}
if _, ok := d.dialing[n.ID()]; ok {
return errAlreadyDialing
}

View file

@ -250,10 +250,10 @@ func TestDialSchedManyStaticNodes(t *testing.T) {
uintID(0xFFFF),
},
wantNewDials: []*enode.Node{
newNode(uintID(0x0321), "127.0.0.1:30303"),
newNode(uintID(0x02E2), "127.0.0.1:30303"),
newNode(uintID(0x01E2), "127.0.0.1:30303"),
newNode(uintID(0x03D5), "127.0.0.1:30303"),
newNode(uintID(0x0085), "127.0.0.1:30303"),
newNode(uintID(0x02dc), "127.0.0.1:30303"),
newNode(uintID(0x0285), "127.0.0.1:30303"),
newNode(uintID(0x00cb), "127.0.0.1:30303"),
},
},
})

View file

@ -596,6 +596,7 @@ func (srv *Server) setupDiscovery() error {
func (srv *Server) setupDialScheduler() {
config := dialConfig{
self: srv.localnode.ID(),
maxDialPeers: srv.maxDialedConns(),
maxActiveDials: srv.MaxPendingPeers,
resolver: srv.ntab,