From d26b8b2d43c9fda964573e9b90b3da455db0529b Mon Sep 17 00:00:00 2001
From: "Owain G. Ainsworth" <oga@conformal.com>
Date: Fri, 18 Oct 2013 18:48:51 +0100
Subject: [PATCH] Set peer.timeConnected when we are actualy connected.

---
 peer.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/peer.go b/peer.go
index a35715aa..be16a2ac 100644
--- a/peer.go
+++ b/peer.go
@@ -1262,7 +1262,6 @@ func newPeerBase(s *server, inbound bool) *peer {
 		protocolVersion: btcwire.ProtocolVersion,
 		btcnet:          s.btcnet,
 		services:        btcwire.SFNodeNetwork,
-		timeConnected:   time.Now(),
 		inbound:         inbound,
 		knownAddresses:  make(map[string]bool),
 		knownInventory:  NewMruInventoryMap(maxKnownInventory),
@@ -1285,6 +1284,7 @@ func newInboundPeer(s *server, conn net.Conn) *peer {
 	p := newPeerBase(s, true)
 	p.conn = conn
 	p.addr = conn.RemoteAddr().String()
+	p.timeConnected = time.Now()
 	atomic.AddInt32(&p.connected, 1)
 	return p
 }
@@ -1362,6 +1362,7 @@ func newOutboundPeer(s *server, addr string, persistent bool) *peer {
 			// may have scheduled a shutdown.  In that case ditch
 			// the peer immediately.
 			if atomic.LoadInt32(&p.disconnect) == 0 {
+				p.timeConnected = time.Now()
 				p.server.addrManager.Attempt(p.na)
 
 				// Connection was successful so log it and start peer.