36 *output = length + offset;
40 std::size_t bytesLength =
intToBuffer(length, output + 1);
48 *output = bytesLength + offset + 55;
49 return bytesLength + 1;
68 *output = *(input->
buffer);
73 memcpy(output + encodedLengthLength, input->
buffer, input->
length);
75 return encodedLengthLength + input->
length;
87 std::size_t payloadLength = 0;
88 for(std::size_t i = 0; i < inputLength; i++) {
90 payloadLength +=
encodeItem(input + i, output + payloadLength + 9);
94 std::size_t encodedLengthLength =
encodeLength(payloadLength, 0xc0, output);
97 memmove(output + encodedLengthLength, output + 9, payloadLength);
99 return encodedLengthLength + payloadLength;
Functions for Recursive Length Prefix Encoding. It is the main encoding method used to serialize obje...
Definition: rlp.hpp:17
std::size_t encodeList(Item input[], std::size_t inputLength, Buffer output)
Encodes list of items.
Definition: rlp.hpp:86
std::size_t encodeItem(Item *input, Buffer output)
Encodes single item.
Definition: rlp.hpp:59
std::size_t encodeLength(std::size_t length, std::size_t offset, Buffer output)
Encodes length.
Definition: rlp.hpp:34
Namespace holding all converters and other utilities.
Definition: utils.hpp:10
std::size_t intToBuffer(std::uint64_t x, Buffer output)
Converts integer to buffer.
Definition: utils.hpp:122
Byte * Buffer
Definition: utils.hpp:12
Struct holding single item data - its byte representation and length.
Definition: rlp.hpp:21
Buffer buffer
Definition: rlp.hpp:22
std::size_t length
Definition: rlp.hpp:23