Browse Source

p2p: re-check after sleeps (#2664)

* p2p: re-check after sleeps

* use NodeInfo as an interface

* Revert "use NodeInfo as an interface"

This reverts commit 5f7d055e6c.

* Revert "p2p: re-check after sleeps"

This reverts commit 7f41070da0.

* preserve dial to itself

* ignore ensured connections while re-connecting

* re-check after sleep

* keep protocol definition on net addresses

* decrease log level

* Revert "preserve dial to itself"

This reverts commit 0c6e0fc58d.

* correct func comment according to modification

Co-Authored-By: mgurevin <mehmet@gurevin.net>
pull/2807/head
Mehmet Gurevin 6 years ago
committed by Ethan Buchman
parent
commit
905abf1388
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      p2p/switch.go

+ 10
- 2
p2p/switch.go View File

@ -328,6 +328,11 @@ func (sw *Switch) reconnectToPeer(addr *NetAddress) {
return
}
if sw.IsDialingOrExistingAddress(addr) {
sw.Logger.Debug("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
@ -415,12 +420,15 @@ 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)
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) {


Loading…
Cancel
Save