|
|
@ -325,6 +325,11 @@ func (sw *Switch) reconnectToPeer(addr *NetAddress) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if sw.IsDialingOrExistingAddress(addr) { |
|
|
|
sw.Logger.Info("Peer connection has been established or dialed while we waiting next try", "addr", addr) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err := sw.DialPeerWithAddress(addr, true) |
|
|
|
if err == nil { |
|
|
|
return // success
|
|
|
@ -412,12 +417,16 @@ func (sw *Switch) DialPeersAsync(addrBook AddrBook, peers []string, persistent b |
|
|
|
if addr.Same(ourAddr) { |
|
|
|
sw.Logger.Debug("Ignore attempt to connect to ourselves", "addr", addr, "ourAddr", ourAddr) |
|
|
|
return |
|
|
|
} else if sw.IsDialingOrExistingAddress(addr) { |
|
|
|
} |
|
|
|
|
|
|
|
sw.randomSleep(0) |
|
|
|
|
|
|
|
// check the destination address in established/dialed peers after sleep.
|
|
|
|
if sw.IsDialingOrExistingAddress(addr) { |
|
|
|
sw.Logger.Debug("Ignore attempt to connect to an existing peer", "addr", addr) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
sw.randomSleep(0) |
|
|
|
err := sw.DialPeerWithAddress(addr, persistent) |
|
|
|
if err != nil { |
|
|
|
switch err.(type) { |
|
|
|