diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-26 17:24:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-26 17:24:44 +0800 |
commit | 41bd38147c2e5968283facf641b2444c09f53d14 (patch) | |
tree | 69353d4174e2a244c48eb1faa37d74077b9495d2 /peer.go | |
parent | 92ffc1cc4c7227de93d933181a30c57c5730c41f (diff) | |
download | go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar.gz go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar.bz2 go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar.lz go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar.xz go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.tar.zst go-tangerine-41bd38147c2e5968283facf641b2444c09f53d14.zip |
Clean up and util methods
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -4,15 +4,16 @@ import ( "bytes" "container/list" "fmt" - "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethlog" - "github.com/ethereum/eth-go/ethutil" - "github.com/ethereum/eth-go/ethwire" "net" "strconv" "strings" "sync/atomic" "time" + + "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethlog" + "github.com/ethereum/eth-go/ethutil" + "github.com/ethereum/eth-go/ethwire" ) var peerlogger = ethlog.NewLogger("PEER") @@ -197,10 +198,12 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { } func (self *Peer) Connect(addr string) (conn net.Conn, err error) { - for attempts := 0; attempts < 5; attempts++ { + const maxTries = 3 + for attempts := 0; attempts < maxTries; attempts++ { conn, err = net.DialTimeout("tcp", addr, 10*time.Second) if err != nil { - peerlogger.Debugf("Peer connection failed. Retrying (%d/5)\n", attempts+1) + //peerlogger.Debugf("Peer connection failed. Retrying (%d/%d) (%s)\n", attempts+1, maxTries, addr) + time.Sleep(time.Duration(attempts*20) * time.Second) continue } |