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.
This commit is contained in:
Dave Collins 2014-03-28 14:50:02 -05:00
parent 444d05eafc
commit 886281993a

View file

@ -22,6 +22,9 @@ import (
) )
const ( const (
// maxProtocolVersion is the max protocol version the peer supports.
maxProtocolVersion = 70001
// outputBufferSize is the number of elements the output channels use. // outputBufferSize is the number of elements the output channels use.
outputBufferSize = 50 outputBufferSize = 50
@ -259,6 +262,9 @@ func (p *peer) pushVersionMsg() error {
// Advertise that we're a full node. // Advertise that we're a full node.
msg.Services = btcwire.SFNodeNetwork msg.Services = btcwire.SFNodeNetwork
// Advertise our max supported protocol version.
msg.ProtocolVersion = maxProtocolVersion
p.QueueMessage(msg, nil) p.QueueMessage(msg, nil)
return nil return nil
} }
@ -1540,7 +1546,7 @@ func (p *peer) Shutdown() {
func newPeerBase(s *server, inbound bool) *peer { func newPeerBase(s *server, inbound bool) *peer {
p := peer{ p := peer{
server: s, server: s,
protocolVersion: btcwire.ProtocolVersion, protocolVersion: maxProtocolVersion,
btcnet: s.btcnet, btcnet: s.btcnet,
services: btcwire.SFNodeNetwork, services: btcwire.SFNodeNetwork,
inbound: inbound, inbound: inbound,