Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.h
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static constexpr size_t MESSAGE_SIZE_OFFSET = | ||||
MESSAGE_START_SIZE + COMMAND_SIZE; | MESSAGE_START_SIZE + COMMAND_SIZE; | ||||
static constexpr size_t CHECKSUM_OFFSET = | static constexpr size_t CHECKSUM_OFFSET = | ||||
MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE; | MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE; | ||||
static constexpr size_t HEADER_SIZE = | static constexpr size_t HEADER_SIZE = | ||||
MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE; | MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE; | ||||
typedef std::array<uint8_t, MESSAGE_START_SIZE> MessageMagic; | typedef std::array<uint8_t, MESSAGE_START_SIZE> MessageMagic; | ||||
explicit CMessageHeader(const MessageMagic &pchMessageStartIn); | explicit CMessageHeader(const MessageMagic &pchMessageStartIn); | ||||
/** | |||||
* 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. | |||||
*/ | |||||
CMessageHeader(const MessageMagic &pchMessageStartIn, | CMessageHeader(const MessageMagic &pchMessageStartIn, | ||||
const char *pszCommand, unsigned int nMessageSizeIn); | const char *pszCommand, unsigned int nMessageSizeIn); | ||||
std::string GetCommand() const; | std::string GetCommand() const; | ||||
bool IsValid(const Config &config) const; | bool IsValid(const Config &config) const; | ||||
bool IsValidWithoutConfig(const MessageMagic &magic) const; | bool IsValidWithoutConfig(const MessageMagic &magic) const; | ||||
bool IsOversized(const Config &config) const; | bool IsOversized(const Config &config) const; | ||||
▲ Show 20 Lines • Show All 413 Lines • Show Last 20 Lines |