From 886281993a3b1e7a1452037762a42adee33b7bb1 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 28 Mar 2014 14:50:02 -0500 Subject: [PATCH] Use separate max protocol version. This commit modifies peers to use a max protocol version that is specified as a constant in the peer code as opposed to the btcwire.ProtocolVersion constant. This allows btcwire to be updated to support new protocol versions without causing peers to claim they support a protocol version which they actually don't. --- peer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index 2dcb7233..435b0366 100644 --- a/peer.go +++ b/peer.go @@ -22,6 +22,9 @@ import ( ) const ( + // maxProtocolVersion is the max protocol version the peer supports. + maxProtocolVersion = 70001 + // outputBufferSize is the number of elements the output channels use. outputBufferSize = 50 @@ -259,6 +262,9 @@ func (p *peer) pushVersionMsg() error { // Advertise that we're a full node. msg.Services = btcwire.SFNodeNetwork + // Advertise our max supported protocol version. + msg.ProtocolVersion = maxProtocolVersion + p.QueueMessage(msg, nil) return nil } @@ -1540,7 +1546,7 @@ func (p *peer) Shutdown() { func newPeerBase(s *server, inbound bool) *peer { p := peer{ server: s, - protocolVersion: btcwire.ProtocolVersion, + protocolVersion: maxProtocolVersion, btcnet: s.btcnet, services: btcwire.SFNodeNetwork, inbound: inbound,