From 41d2d366430f768cae5d3d5dc0288d7b6fef06d9 Mon Sep 17 00:00:00 2001 From: "Owain G. Ainsworth" Date: Thu, 21 Nov 2013 19:05:14 +0000 Subject: [PATCH] Only update p.na on reciept of version message for inbound peers. Outbound we already have the exact same thing set up, and this should quieten the race detector. Please note that this does *not* cause problems with the service flags being wrong. Since by this point we have already done every thing that would use the service flags from p.na in addrmanager, and now p.Services is correct.. --- peer.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/peer.go b/peer.go index bdecc4b2..496c7b07 100644 --- a/peer.go +++ b/peer.go @@ -261,16 +261,18 @@ func (p *peer) handleVersionMsg(msg *btcwire.MsgVersion) { p.Disconnect() return } - } - // Set up a NetAddress for the peer to be used with AddrManager. - na, err := newNetAddress(p.conn.RemoteAddr(), p.services) - if err != nil { - p.logError("PEER: Can't get remote address: %v", err) - p.Disconnect() - return + // Set up a NetAddress for the peer to be used with AddrManager. + // We only do this inbound because outbound set this up + // at connection time and no point recomputing. + na, err := newNetAddress(p.conn.RemoteAddr(), p.services) + if err != nil { + p.logError("PEER: Can't get remote address: %v", err) + p.Disconnect() + return + } + p.na = na } - p.na = na // Send verack. p.QueueMessage(btcwire.NewMsgVerAck(), nil)