Bitcoin Core  0.21.1
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
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 unsigned char MessageStartChars [MESSAGE_START_SIZE]
 

Public Member Functions

 CMessageHeader ()
 
 CMessageHeader (const MessageStartChars &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 IsCommandValid () const
 
 SERIALIZE_METHODS (CMessageHeader, obj)
 

Public Attributes

char pchMessageStart [MESSAGE_START_SIZE]
 
char pchCommand [COMMAND_SIZE]
 
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 = MESSAGE_START_SIZE + COMMAND_SIZE
 
static constexpr size_t CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE
 
static constexpr size_t HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
 

Detailed Description

Message header.

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

Definition at line 28 of file protocol.h.

Member Typedef Documentation

typedef unsigned char CMessageHeader::MessageStartChars[MESSAGE_START_SIZE]

Definition at line 38 of file protocol.h.

Constructor & Destructor Documentation

CMessageHeader::CMessageHeader ( )
explicit

Definition at line 91 of file protocol.cpp.

CMessageHeader::CMessageHeader ( const MessageStartChars 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 99 of file protocol.cpp.

Here is the call graph for this function:

Member Function Documentation

std::string CMessageHeader::GetCommand ( ) const

Definition at line 113 of file protocol.cpp.

Here is the call graph for this function:

bool CMessageHeader::IsCommandValid ( ) const

Definition at line 118 of file protocol.cpp.

CMessageHeader::SERIALIZE_METHODS ( CMessageHeader  ,
obj   
)
inline

Definition at line 50 of file protocol.h.

Member Data Documentation

constexpr size_t CMessageHeader::CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE
static

Definition at line 36 of file protocol.h.

constexpr size_t CMessageHeader::CHECKSUM_SIZE = 4
static

Definition at line 34 of file protocol.h.

constexpr size_t CMessageHeader::COMMAND_SIZE = 12
static

Definition at line 32 of file protocol.h.

constexpr size_t CMessageHeader::HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
static

Definition at line 37 of file protocol.h.

constexpr size_t CMessageHeader::MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE
static

Definition at line 35 of file protocol.h.

constexpr size_t CMessageHeader::MESSAGE_SIZE_SIZE = 4
static

Definition at line 33 of file protocol.h.

constexpr size_t CMessageHeader::MESSAGE_START_SIZE = 4
static

Definition at line 31 of file protocol.h.

uint32_t CMessageHeader::nMessageSize

Definition at line 54 of file protocol.h.

uint8_t CMessageHeader::pchChecksum[CHECKSUM_SIZE]

Definition at line 55 of file protocol.h.

char CMessageHeader::pchCommand[COMMAND_SIZE]

Definition at line 53 of file protocol.h.

char CMessageHeader::pchMessageStart[MESSAGE_START_SIZE]

Definition at line 52 of file protocol.h.


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