Skip to content

rlp/constants.hpp

Namespaces

Name
rlp

Classes

Name
struct rlp::Header

Types

Name
enum class Leftover

Attributes

Name
uint8_t kEmptyStringCode
uint8_t kEmptyListCode
uint8_t kMaxShortStringLen
uint8_t kMaxShortListLen
uint8_t kShortStringOffset
uint8_t kLongStringOffset
uint8_t kShortListOffset
uint8_t kLongListOffset
uint8_t kRlpSingleByteThreshold
size_t kLongPrefixByteSize
Size of the single prefix byte prepended before the big-endian length field in long strings/lists.
size_t kSingleByteStringSize
Minimum encoded size of a single-byte RLP string (prefix byte + payload byte).

Types Documentation

enum Leftover

Enumerator Value Description
kProhibit
kAllow

Attributes Documentation

variable kEmptyStringCode

uint8_t kEmptyStringCode {0x80};

variable kEmptyListCode

uint8_t kEmptyListCode {0xC0};

variable kMaxShortStringLen

uint8_t kMaxShortStringLen {55};

variable kMaxShortListLen

uint8_t kMaxShortListLen {55};

variable kShortStringOffset

uint8_t kShortStringOffset {0x80};

variable kLongStringOffset

uint8_t kLongStringOffset {0xB7};

variable kShortListOffset

uint8_t kShortListOffset {0xC0};

variable kLongListOffset

uint8_t kLongListOffset {0xF7};

variable kRlpSingleByteThreshold

uint8_t kRlpSingleByteThreshold {0x80};

variable kLongPrefixByteSize

size_t kLongPrefixByteSize {1};

Size of the single prefix byte prepended before the big-endian length field in long strings/lists.

variable kSingleByteStringSize

size_t kSingleByteStringSize {2};

Minimum encoded size of a single-byte RLP string (prefix byte + payload byte).

Source code

#ifndef RLP_CONSTANTS_HPP
#define RLP_CONSTANTS_HPP

#include <cstdint>

namespace rlp {

// RLP encoding constants
inline constexpr uint8_t kEmptyStringCode{0x80};
inline constexpr uint8_t kEmptyListCode{0xC0};
inline constexpr uint8_t kMaxShortStringLen{55}; // 0xB7 - 0x80
inline constexpr uint8_t kMaxShortListLen{55}; // 0xF7 - 0xC0
inline constexpr uint8_t kShortStringOffset{0x80};
inline constexpr uint8_t kLongStringOffset{0xB7}; // 0x80 + 55 + 1
inline constexpr uint8_t kShortListOffset{0xC0};
inline constexpr uint8_t kLongListOffset{0xF7}; // 0xC0 + 55 + 1
inline constexpr uint8_t kRlpSingleByteThreshold{0x80};  // Values below this are encoded as a single byte

inline constexpr size_t kLongPrefixByteSize{1};

inline constexpr size_t kSingleByteStringSize{2};

// RLP header structure (internal use)
struct Header {
    bool list{false};
    size_t payload_size_bytes{0};  // Size of payload in bytes (not item count for lists)
    size_t header_size_bytes{0};   // Size of the RLP header/prefix itself in bytes
};

// Leftover handling mode for decoding
enum class Leftover {
    kProhibit,
    kAllow,
};

} // namespace rlp

#endif // RLP_CONSTANTS_HPP

Updated on 2026-04-13 at 23:22:46 -0700