Export MaxVarIntPayload.
This commit is contained in:
parent
b9c21bd518
commit
e5d15b0fa8
9 changed files with 10 additions and 10 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue