Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
CMessageHeader Class Reference

Message header. More...

#include <protocol.h>

Public Member Functions

 CMessageHeader ()=default
 
 CMessageHeader (const MessageStartChars &pchMessageStartIn, const char *msg_type, unsigned int nMessageSizeIn)
 Construct a P2P message header from message-start characters, a message type and the size of the message. More...
 
std::string GetMessageType () const
 
bool IsMessageTypeValid () const
 
 SERIALIZE_METHODS (CMessageHeader, obj)
 

Public Attributes

MessageStartChars pchMessageStart {}
 
char m_msg_type [MESSAGE_TYPE_SIZE] {}
 
uint32_t nMessageSize {std::numeric_limits<uint32_t>::max()}
 
uint8_t pchChecksum [CHECKSUM_SIZE] {}
 

Static Public Attributes

static constexpr size_t MESSAGE_TYPE_SIZE = 12
 
static constexpr size_t MESSAGE_SIZE_SIZE = 4
 
static constexpr size_t CHECKSUM_SIZE = 4
 
static constexpr size_t MESSAGE_SIZE_OFFSET = std::tuple_size_v<MessageStartChars> + MESSAGE_TYPE_SIZE
 
static constexpr size_t CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE
 
static constexpr size_t HEADER_SIZE = std::tuple_size_v<MessageStartChars> + MESSAGE_TYPE_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
 

Detailed Description

Message header.

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

Definition at line 28 of file protocol.h.

Constructor & Destructor Documentation

◆ CMessageHeader() [1/2]

CMessageHeader::CMessageHeader ( )
explicitdefault

◆ CMessageHeader() [2/2]

CMessageHeader::CMessageHeader ( const MessageStartChars pchMessageStartIn,
const char *  msg_type,
unsigned int  nMessageSizeIn 
)

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

Note
Passing in a msg_type longer than MESSAGE_TYPE_SIZE will result in a run-time assertion error.

Definition at line 10 of file protocol.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ GetMessageType()

std::string CMessageHeader::GetMessageType ( ) const

Definition at line 21 of file protocol.cpp.

◆ IsMessageTypeValid()

bool CMessageHeader::IsMessageTypeValid ( ) const

Definition at line 26 of file protocol.cpp.

◆ SERIALIZE_METHODS()

CMessageHeader::SERIALIZE_METHODS ( CMessageHeader  ,
obj   
)
inline

Definition at line 48 of file protocol.h.

Member Data Documentation

◆ CHECKSUM_OFFSET

constexpr size_t CMessageHeader::CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE
staticconstexpr

Definition at line 35 of file protocol.h.

◆ CHECKSUM_SIZE

constexpr size_t CMessageHeader::CHECKSUM_SIZE = 4
staticconstexpr

Definition at line 33 of file protocol.h.

◆ HEADER_SIZE

constexpr size_t CMessageHeader::HEADER_SIZE = std::tuple_size_v<MessageStartChars> + MESSAGE_TYPE_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
staticconstexpr

Definition at line 36 of file protocol.h.

◆ m_msg_type

char CMessageHeader::m_msg_type[MESSAGE_TYPE_SIZE] {}

Definition at line 51 of file protocol.h.

◆ MESSAGE_SIZE_OFFSET

constexpr size_t CMessageHeader::MESSAGE_SIZE_OFFSET = std::tuple_size_v<MessageStartChars> + MESSAGE_TYPE_SIZE
staticconstexpr

Definition at line 34 of file protocol.h.

◆ MESSAGE_SIZE_SIZE

constexpr size_t CMessageHeader::MESSAGE_SIZE_SIZE = 4
staticconstexpr

Definition at line 32 of file protocol.h.

◆ MESSAGE_TYPE_SIZE

constexpr size_t CMessageHeader::MESSAGE_TYPE_SIZE = 12
staticconstexpr

Definition at line 31 of file protocol.h.

◆ nMessageSize

uint32_t CMessageHeader::nMessageSize {std::numeric_limits<uint32_t>::max()}

Definition at line 52 of file protocol.h.

◆ pchChecksum

uint8_t CMessageHeader::pchChecksum[CHECKSUM_SIZE] {}

Definition at line 53 of file protocol.h.

◆ pchMessageStart

MessageStartChars CMessageHeader::pchMessageStart {}

Definition at line 50 of file protocol.h.


The documentation for this class was generated from the following files: