Kagome
Polkadot Runtime Engine in C++17
|
#include <polkadot_codec.hpp>
Public Types | |
enum | Error { Error::SUCCESS = 0, Error::TOO_MANY_NIBBLES, Error::UNKNOWN_NODE_TYPE, Error::INPUT_TOO_SMALL, Error::NO_NODE_VALUE } |
using | Buffer = common::Buffer |
using | BufferView = common::BufferView |
Public Types inherited from kagome::storage::trie::Codec | |
using | StoreChildren = std::function< outcome::result< void >(common::BufferView, common::Buffer &&)> |
Public Member Functions | |
~PolkadotCodec () override=default | |
outcome::result< Buffer > | encodeNodeAndStoreChildren (const Node &node, const StoreChildren &store_children) const override |
Encode node to byte representation and store children. More... | |
outcome::result< std::shared_ptr< Node > > | decodeNode (gsl::span< const uint8_t > encoded_data) const override |
Decode node from bytes. More... | |
common::Buffer | merkleValue (const BufferView &buf) const override |
Get the merkle value of a node. More... | |
bool | isMerkleHash (const common::BufferView &buf) const override |
is this a hash of value, or value itself More... | |
common::Hash256 | hash256 (const BufferView &buf) const override |
Get the hash of a node. More... | |
outcome::result< Buffer > | encodeHeader (const TrieNode &node) const |
Public Member Functions inherited from kagome::storage::trie::Codec | |
virtual | ~Codec ()=default |
outcome::result< common::Buffer > | encodeNode (const Node &node) const |
Encode node to byte representation. More... | |
Private Member Functions | |
outcome::result< Buffer > | encodeBranch (const BranchNode &node, const StoreChildren &store_children) const |
outcome::result< Buffer > | encodeLeaf (const LeafNode &node) const |
outcome::result< std::pair< TrieNode::Type, size_t > > | decodeHeader (BufferStream &stream) const |
outcome::result< KeyNibbles > | decodePartialKey (size_t nibbles_num, BufferStream &stream) const |
outcome::result< std::shared_ptr< Node > > | decodeBranch (TrieNode::Type type, const KeyNibbles &partial_key, BufferStream &stream) const |
Definition at line 19 of file polkadot_codec.hpp.
Definition at line 21 of file polkadot_codec.hpp.
Definition at line 22 of file polkadot_codec.hpp.
|
strong |
Definition at line 24 of file polkadot_codec.hpp.
|
overridedefault |
|
private |
Definition at line 338 of file polkadot_codec.cpp.
|
private |
Definition at line 265 of file polkadot_codec.cpp.
|
overridevirtual |
Decode node from bytes.
encoded_data | a buffer containing encoded representation of a node |
Implements kagome::storage::trie::Codec.
Definition at line 225 of file polkadot_codec.cpp.
|
private |
Definition at line 317 of file polkadot_codec.cpp.
|
private |
Definition at line 170 of file polkadot_codec.cpp.
outcome::result< common::Buffer > kagome::storage::trie::PolkadotCodec::encodeHeader | ( | const TrieNode & | node | ) | const |
Encodes a node header according to the specification
Definition at line 103 of file polkadot_codec.cpp.
|
private |
Definition at line 210 of file polkadot_codec.cpp.
|
overridevirtual |
Encode node to byte representation and store children.
node | node in the trie |
store_children | chidren storer |
node} |
Implements kagome::storage::trie::Codec.
Definition at line 70 of file polkadot_codec.cpp.
|
overridevirtual |
Get the hash of a node.
buf | byte representation of the node |
buf |
Implements kagome::storage::trie::Codec.
Definition at line 57 of file polkadot_codec.cpp.
|
overridevirtual |
is this a hash of value, or value itself
Implements kagome::storage::trie::Codec.
Definition at line 51 of file polkadot_codec.cpp.
|
overridevirtual |
Get the merkle value of a node.
buf | byte representation of the node |
buf | or |
buf | if it is shorter than the hash |
Implements kagome::storage::trie::Codec.
Definition at line 40 of file polkadot_codec.cpp.