Bitcoin ABC  0.24.7
P2P Digital Currency
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
CMessageHeader Class Reference

Message header. More...

#include <protocol.h>

Public Types

typedef std::array< uint8_t, MESSAGE_START_SIZEMessageMagic
 

Public Member Functions

 CMessageHeader (const MessageMagic &pchMessageStartIn)
 
 CMessageHeader (const MessageMagic &pchMessageStartIn, const char *pszCommand, unsigned int nMessageSizeIn)
 Construct a P2P message header from message-start characters, a command and the size of the message. More...
 
std::string GetCommand () const
 
bool IsValid (const Config &config) const
 
bool IsValidWithoutConfig (const MessageMagic &magic) const
 This is a transition method in order to stay compatible with older code that do not use the config. More...
 
bool IsOversized (const Config &config) const
 
 SERIALIZE_METHODS (CMessageHeader, obj)
 

Public Attributes

MessageMagic pchMessageStart
 
std::array< char, COMMAND_SIZEpchCommand
 
uint32_t nMessageSize
 
uint8_t pchChecksum [CHECKSUM_SIZE]
 

Static Public Attributes

static constexpr size_t MESSAGE_START_SIZE = 4
 
static constexpr size_t COMMAND_SIZE = 12
 
static constexpr size_t MESSAGE_SIZE_SIZE = 4
 
static constexpr size_t CHECKSUM_SIZE = 4
 
static constexpr size_t MESSAGE_SIZE_OFFSET
 
static constexpr size_t CHECKSUM_OFFSET
 
static constexpr size_t HEADER_SIZE
 

Detailed Description

Message header.

(4) message start. (12) command. (4) size. (4) checksum.

Definition at line 37 of file protocol.h.

Member Typedef Documentation

◆ MessageMagic

typedef std::array<uint8_t, MESSAGE_START_SIZE> CMessageHeader::MessageMagic

Definition at line 49 of file protocol.h.

Constructor & Destructor Documentation

◆ CMessageHeader() [1/2]

CMessageHeader::CMessageHeader ( const MessageMagic pchMessageStartIn)
explicit

Definition at line 84 of file protocol.cpp.

◆ CMessageHeader() [2/2]

CMessageHeader::CMessageHeader ( const MessageMagic pchMessageStartIn,
const char *  pszCommand,
unsigned int  nMessageSizeIn 
)

Construct a P2P message header from message-start characters, a command and the size of the message.

Note
Passing in a pszCommand longer than COMMAND_SIZE will result in a run-time assertion error.

Definition at line 92 of file protocol.cpp.

Member Function Documentation

◆ GetCommand()

std::string CMessageHeader::GetCommand ( ) const

Definition at line 112 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsOversized()

bool CMessageHeader::IsOversized ( const Config config) const

Definition at line 188 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValid()

bool CMessageHeader::IsValid ( const Config config) const

Definition at line 147 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidWithoutConfig()

bool CMessageHeader::IsValidWithoutConfig ( const MessageMagic magic) const

This is a transition method in order to stay compatible with older code that do not use the config.

It assumes message will not get too large. This cannot be used for any piece of code that will download blocks as blocks may be bigger than the permitted size. Idealy, code that uses this function should be migrated toward using the config.

Definition at line 171 of file protocol.cpp.

Here is the call graph for this function:

◆ SERIALIZE_METHODS()

CMessageHeader::SERIALIZE_METHODS ( CMessageHeader  ,
obj   
)
inline

Definition at line 67 of file protocol.h.

Member Data Documentation

◆ CHECKSUM_OFFSET

constexpr size_t CMessageHeader::CHECKSUM_OFFSET
staticconstexpr
Initial value:

Definition at line 45 of file protocol.h.

◆ CHECKSUM_SIZE

constexpr size_t CMessageHeader::CHECKSUM_SIZE = 4
staticconstexpr

Definition at line 42 of file protocol.h.

◆ COMMAND_SIZE

constexpr size_t CMessageHeader::COMMAND_SIZE = 12
staticconstexpr

Definition at line 40 of file protocol.h.

◆ HEADER_SIZE

constexpr size_t CMessageHeader::HEADER_SIZE
staticconstexpr
Initial value:

Definition at line 47 of file protocol.h.

◆ MESSAGE_SIZE_OFFSET

constexpr size_t CMessageHeader::MESSAGE_SIZE_OFFSET
staticconstexpr
Initial value:

Definition at line 43 of file protocol.h.

◆ MESSAGE_SIZE_SIZE

constexpr size_t CMessageHeader::MESSAGE_SIZE_SIZE = 4
staticconstexpr

Definition at line 41 of file protocol.h.

◆ MESSAGE_START_SIZE

constexpr size_t CMessageHeader::MESSAGE_START_SIZE = 4
staticconstexpr

Definition at line 39 of file protocol.h.

◆ nMessageSize

uint32_t CMessageHeader::nMessageSize

Definition at line 74 of file protocol.h.

◆ pchChecksum

uint8_t CMessageHeader::pchChecksum[CHECKSUM_SIZE]

Definition at line 75 of file protocol.h.

◆ pchCommand

std::array<char, COMMAND_SIZE> CMessageHeader::pchCommand

Definition at line 73 of file protocol.h.

◆ pchMessageStart

MessageMagic CMessageHeader::pchMessageStart

Definition at line 72 of file protocol.h.


The documentation for this class was generated from the following files:
CMessageHeader::MESSAGE_SIZE_SIZE
static constexpr size_t MESSAGE_SIZE_SIZE
Definition: protocol.h:41
CMessageHeader::MESSAGE_SIZE_OFFSET
static constexpr size_t MESSAGE_SIZE_OFFSET
Definition: protocol.h:43
CMessageHeader::COMMAND_SIZE
static constexpr size_t COMMAND_SIZE
Definition: protocol.h:40
CMessageHeader::MESSAGE_START_SIZE
static constexpr size_t MESSAGE_START_SIZE
Definition: protocol.h:39
CMessageHeader::CHECKSUM_SIZE
static constexpr size_t CHECKSUM_SIZE
Definition: protocol.h:42