Bitcoin ABC 0.30.5
P2P Digital Currency
|
Message header. More...
#include <protocol.h>
Public Types | |
typedef std::array< uint8_t, MESSAGE_START_SIZE > | MessageMagic |
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_SIZE > | pchCommand |
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 |
Message header.
(4) message start. (12) command. (4) size. (4) checksum.
Definition at line 34 of file protocol.h.
typedef std::array<uint8_t, MESSAGE_START_SIZE> CMessageHeader::MessageMagic |
Definition at line 46 of file protocol.h.
|
explicit |
Definition at line 91 of file protocol.cpp.
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.
pszCommand
longer than COMMAND_SIZE will result in a run-time assertion error. Definition at line 99 of file protocol.cpp.
std::string CMessageHeader::GetCommand | ( | ) | const |
Definition at line 119 of file protocol.cpp.
bool CMessageHeader::IsOversized | ( | const Config & | config | ) | const |
Definition at line 194 of file protocol.cpp.
bool CMessageHeader::IsValid | ( | const Config & | config | ) | const |
Definition at line 153 of file protocol.cpp.
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 177 of file protocol.cpp.
|
inline |
Definition at line 64 of file protocol.h.
|
staticconstexpr |
Definition at line 42 of file protocol.h.
|
staticconstexpr |
Definition at line 39 of file protocol.h.
|
staticconstexpr |
Definition at line 37 of file protocol.h.
|
staticconstexpr |
Definition at line 44 of file protocol.h.
|
staticconstexpr |
Definition at line 40 of file protocol.h.
|
staticconstexpr |
Definition at line 38 of file protocol.h.
|
staticconstexpr |
Definition at line 36 of file protocol.h.
uint32_t CMessageHeader::nMessageSize |
Definition at line 71 of file protocol.h.
uint8_t CMessageHeader::pchChecksum[CHECKSUM_SIZE] |
Definition at line 72 of file protocol.h.
std::array<char, COMMAND_SIZE> CMessageHeader::pchCommand |
Definition at line 70 of file protocol.h.
MessageMagic CMessageHeader::pchMessageStart |
Definition at line 69 of file protocol.h.