From e5d15b0fa8a1e311fef6925502761c9f27bf292d Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 11 Mar 2014 20:09:55 -0500 Subject: [PATCH] Export MaxVarIntPayload. --- common.go | 2 +- msgaddr.go | 4 ++-- msggetblocks.go | 2 +- msggetdata.go | 2 +- msggetheaders.go | 2 +- msgheaders.go | 2 +- msginv.go | 2 +- msgnotfound.go | 2 +- msgversion.go | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common.go b/common.go index 375bff0a..e8f34f4f 100644 --- a/common.go +++ b/common.go @@ -14,7 +14,7 @@ import ( ) // Maximum payload size for a variable length integer. -const maxVarIntPayload = 9 +const MaxVarIntPayload = 9 // readElement reads the next sequence of bytes from r using little endian // depending on the concrete type of element pointed to. diff --git a/msgaddr.go b/msgaddr.go index 800e65fa..678de22d 100644 --- a/msgaddr.go +++ b/msgaddr.go @@ -126,11 +126,11 @@ func (msg *MsgAddr) Command() string { func (msg *MsgAddr) MaxPayloadLength(pver uint32) uint32 { if pver < MultipleAddressVersion { // Num addresses (varInt) + a single net addresses. - return maxVarIntPayload + maxNetAddressPayload(pver) + return MaxVarIntPayload + maxNetAddressPayload(pver) } // Num addresses (varInt) + max allowed addresses. - return maxVarIntPayload + (MaxAddrPerMsg * maxNetAddressPayload(pver)) + return MaxVarIntPayload + (MaxAddrPerMsg * maxNetAddressPayload(pver)) } // NewMsgAddr returns a new bitcoin addr message that conforms to the diff --git a/msggetblocks.go b/msggetblocks.go index 1996ae44..45ec0d47 100644 --- a/msggetblocks.go +++ b/msggetblocks.go @@ -129,7 +129,7 @@ func (msg *MsgGetBlocks) Command() string { func (msg *MsgGetBlocks) MaxPayloadLength(pver uint32) uint32 { // Protocol version 4 bytes + num hashes (varInt) + max block locator // hashes + hash stop. - return 4 + maxVarIntPayload + (MaxBlockLocatorsPerMsg * HashSize) + HashSize + return 4 + MaxVarIntPayload + (MaxBlockLocatorsPerMsg * HashSize) + HashSize } // NewMsgGetBlocks returns a new bitcoin getblocks message that conforms to the diff --git a/msggetdata.go b/msggetdata.go index a7494f70..3add4782 100644 --- a/msggetdata.go +++ b/msggetdata.go @@ -97,7 +97,7 @@ func (msg *MsgGetData) Command() string { // receiver. This is part of the Message interface implementation. func (msg *MsgGetData) MaxPayloadLength(pver uint32) uint32 { // Num inventory vectors (varInt) + max allowed inventory vectors. - return maxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) + return MaxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) } // NewMsgGetData returns a new bitcoin getdata message that conforms to the diff --git a/msggetheaders.go b/msggetheaders.go index bbd6cc17..607fba49 100644 --- a/msggetheaders.go +++ b/msggetheaders.go @@ -127,7 +127,7 @@ func (msg *MsgGetHeaders) Command() string { func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32 { // Version 4 bytes + num block locator hashes (varInt) + max allowed block // locators + hash stop. - return 4 + maxVarIntPayload + (MaxBlockLocatorsPerMsg * HashSize) + HashSize + return 4 + MaxVarIntPayload + (MaxBlockLocatorsPerMsg * HashSize) + HashSize } // NewMsgGetHeaders returns a new bitcoin getheaders message that conforms to diff --git a/msgheaders.go b/msgheaders.go index a9f5fe07..fdb3d5d4 100644 --- a/msgheaders.go +++ b/msgheaders.go @@ -121,7 +121,7 @@ func (msg *MsgHeaders) Command() string { func (msg *MsgHeaders) MaxPayloadLength(pver uint32) uint32 { // Num headers (varInt) + max allowed headers (header length + 1 byte // for the number of transactions which is always 0). - return maxVarIntPayload + ((maxBlockHeaderPayload + 1) * + return MaxVarIntPayload + ((maxBlockHeaderPayload + 1) * MaxBlockHeadersPerMsg) } diff --git a/msginv.go b/msginv.go index 594bda0d..55ca11ca 100644 --- a/msginv.go +++ b/msginv.go @@ -105,7 +105,7 @@ func (msg *MsgInv) Command() string { // receiver. This is part of the Message interface implementation. func (msg *MsgInv) MaxPayloadLength(pver uint32) uint32 { // Num inventory vectors (varInt) + max allowed inventory vectors. - return maxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) + return MaxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) } // NewMsgInv returns a new bitcoin inv message that conforms to the Message diff --git a/msgnotfound.go b/msgnotfound.go index 47188299..fa439f55 100644 --- a/msgnotfound.go +++ b/msgnotfound.go @@ -95,7 +95,7 @@ func (msg *MsgNotFound) Command() string { func (msg *MsgNotFound) MaxPayloadLength(pver uint32) uint32 { // Max var int 9 bytes + max InvVects at 36 bytes each. // Num inventory vectors (varInt) + max allowed inventory vectors. - return maxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) + return MaxVarIntPayload + (MaxInvPerMsg * maxInvVectPayload) } // NewMsgNotFound returns a new bitcoin notfound message that conforms to the diff --git a/msgversion.go b/msgversion.go index 6b215759..0fc18b3f 100644 --- a/msgversion.go +++ b/msgversion.go @@ -167,7 +167,7 @@ func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32 { // Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes + remote // and local net addresses + nonce 8 bytes + length of user agent (varInt) + // max allowed useragent length + last block 4 bytes. - return 32 + (maxNetAddressPayload(pver) * 2) + maxVarIntPayload + MaxUserAgentLen + return 32 + (maxNetAddressPayload(pver) * 2) + MaxVarIntPayload + MaxUserAgentLen } // NewMsgVersion returns a new bitcoin version message that conforms to the