|
@ -325,6 +325,11 @@ func (sw *Switch) reconnectToPeer(addr *NetAddress) { |
|
|
return |
|
|
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) |
|
|
err := sw.DialPeerWithAddress(addr, true) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
return // success
|
|
|
return // success
|
|
@ -412,12 +417,16 @@ func (sw *Switch) DialPeersAsync(addrBook AddrBook, peers []string, persistent b |
|
|
if addr.Same(ourAddr) { |
|
|
if addr.Same(ourAddr) { |
|
|
sw.Logger.Debug("Ignore attempt to connect to ourselves", "addr", addr, "ourAddr", ourAddr) |
|
|
sw.Logger.Debug("Ignore attempt to connect to ourselves", "addr", addr, "ourAddr", ourAddr) |
|
|
return |
|
|
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) |
|
|
sw.Logger.Debug("Ignore attempt to connect to an existing peer", "addr", addr) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sw.randomSleep(0) |
|
|
|
|
|
err := sw.DialPeerWithAddress(addr, persistent) |
|
|
err := sw.DialPeerWithAddress(addr, persistent) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
switch err.(type) { |
|
|
switch err.(type) { |
|
|