Revert "p2p: re-check after sleeps"

This reverts commit 7f41070da0.
This commit is contained in:
Mehmet Gurevin
2018-11-08 17:55:10 +03:00
parent 53704f7405
commit 70cfc731db
3 changed files with 3 additions and 19 deletions
-5
View File
@@ -34,11 +34,6 @@ type NetAddress struct {
// IDAddressString returns id@hostPort.
func IDAddressString(id ID, hostPort string) string {
// we respect the protocol definition in here.
if p := strings.Index(hostPort, "://"); p > -1 {
return fmt.Sprintf("%s://%s@%s", hostPort[:p], id, hostPort[p+3:])
}
return fmt.Sprintf("%s@%s", id, hostPort)
}
+1 -3
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/pkg/errors"
amino "github.com/tendermint/go-amino"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p"
@@ -394,9 +395,6 @@ func (r *PEXReactor) ensurePeers() {
if r.Switch.IsDialingOrExistingAddress(try) {
continue
}
if r.Switch.NodeInfo().ID == try.ID {
continue // we don't want to dial ourselves, usually.
}
// TODO: consider moving some checks from toDial into here
// so we don't even consider dialing peers that we want to wait
// before dialling again, or have dialed too many times already
+2 -11
View File
@@ -325,11 +325,6 @@ 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
@@ -417,16 +412,12 @@ 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
}
sw.randomSleep(0)
// check the destination address in established/dialed peers after sleep.
if sw.IsDialingOrExistingAddress(addr) {
} else 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) {