aboutsummaryrefslogtreecommitdiffstats
path: root/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-24 18:25:41 +0800
committerobscuren <geffobscura@gmail.com>2014-07-24 18:25:41 +0800
commit6d69ca36a755ea44e7ce4ba7b135afb0b9dbff05 (patch)
tree92c51de00221ead1a2d8ac770e090d39ee8ea785 /peer.go
parenta45c08f9fe320d79d2abc7c29e5f3b986130c5bb (diff)
downloadgo-tangerine-6d69ca36a755ea44e7ce4ba7b135afb0b9dbff05.tar.gz
go-tangerine-6d69ca36a755ea44e7ce4ba7b135afb0b9dbff05.tar.zst
go-tangerine-6d69ca36a755ea44e7ce4ba7b135afb0b9dbff05.zip
Peer reconnect attempt
Diffstat (limited to 'peer.go')
-rw-r--r--peer.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/peer.go b/peer.go
index 16340cda5..ac4ba82ab 100644
--- a/peer.go
+++ b/peer.go
@@ -177,10 +177,20 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
// Set up the connection in another goroutine so we don't block the main thread
go func() {
- conn, err := net.DialTimeout("tcp", addr, 10*time.Second)
+ var (
+ err error
+ conn net.Conn
+ )
+
+ for attempts := 0; attempts < 5; attempts++ {
+ conn, err = net.DialTimeout("tcp", addr, 10*time.Second)
+ if err != nil {
+ peerlogger.Debugf("Peer connection failed. Retrying (%d/5)\n", attempts+1)
+ }
+ }
if err != nil {
- peerlogger.Debugln("Connection to peer failed", err)
+ peerlogger.Debugln("Connection to peer failed. Giving up.", err)
p.Stop()
return
}