23 typedef std::vector<uint8_t>
Payload;
31 std::string
type()
const {
return type_; }
34 Payload
payload()
const {
return payload_; }
37 size_t size()
const {
return payload_.size(); }
57 static uint32_t
const MAGIC_MAIN = 0xD9B4BEF9;
58 static uint32_t
const MAGIC_TEST = 0xDAB5BFFA;
59 static uint32_t
const MAGIC_TEST3 = 0x0709110B;
62 static size_t const MAGIC_SIZE = 4;
63 static size_t const TYPE_SIZE = 12;
64 static size_t const LENGTH_SIZE = 4;
65 static size_t const CHECKSUM_SIZE = 4;
68 char type_[TYPE_SIZE];
74 virtual void serialize(std::vector<uint8_t> & out)
const override;
75 virtual json
toJson()
const override;
An abstract class that enables an object to be serialized by the serialization functions.
Definition: Serialize.h:27
void serialize(uint8_t const &a, std::vector< uint8_t > &out)
Serializes a uint8_t.
Definition: Serialize.cpp:10
Payload payload() const
Returns the payload.
Definition: Message.h:34
size_t size() const
Returns the size of the payload.
Definition: Message.h:37
A P2P network message.
Definition: Message.h:16
std::string type() const
Returns the message type.
Definition: Message.h:31
uint32_t checksum() const
Returns the checksum of the payload.
json toJson(std::vector< uint8_t > const &v)
Converts a std::vector<uint8_t> to a JSON hex string toJson.
Definition: Serialize.cpp:144
std::vector< uint8_t > Payload
Contains a message's payload.
Definition: Message.h:20
Message(char const *type, std::vector< uint8_t > const &payload)
Definition: Message.cpp:12
Thrown by a message constructor if the data in the message is invalid.
Definition: Message.h:81