Kagome
Polkadot Runtime Engine in C++17
kagome::storage::trie::Codec Class Referenceabstract

Internal codec for nodes in the Trie. Eth and substrate have different codecs, but rest of the code should be same. More...

#include <codec.hpp>

Inheritance diagram for kagome::storage::trie::Codec:
Collaboration diagram for kagome::storage::trie::Codec:

Public Types

using StoreChildren = std::function< outcome::result< void >(common::BufferView, common::Buffer &&)>
 

Public Member Functions

virtual ~Codec ()=default
 
virtual outcome::result< common::BufferencodeNodeAndStoreChildren (const Node &node, const StoreChildren &store_children) const =0
 Encode node to byte representation and store children. More...
 
outcome::result< common::BufferencodeNode (const Node &node) const
 Encode node to byte representation. More...
 
virtual outcome::result< std::shared_ptr< Node > > decodeNode (gsl::span< const uint8_t > encoded_data) const =0
 Decode node from bytes. More...
 
virtual common::Buffer merkleValue (const common::BufferView &buf) const =0
 Get the merkle value of a node. More...
 
virtual bool isMerkleHash (const common::BufferView &buf) const =0
 is this a hash of value, or value itself More...
 
virtual common::Hash256 hash256 (const common::BufferView &buf) const =0
 Get the hash of a node. More...
 

Detailed Description

Internal codec for nodes in the Trie. Eth and substrate have different codecs, but rest of the code should be same.

Definition at line 18 of file codec.hpp.

Member Typedef Documentation

using kagome::storage::trie::Codec::StoreChildren = std::function<outcome::result<void>( common::BufferView, common::Buffer &&)>

Definition at line 21 of file codec.hpp.

Constructor & Destructor Documentation

virtual kagome::storage::trie::Codec::~Codec ( )
virtualdefault

Member Function Documentation

virtual outcome::result<std::shared_ptr<Node> > kagome::storage::trie::Codec::decodeNode ( gsl::span< const uint8_t >  encoded_data) const
pure virtual

Decode node from bytes.

Parameters
encoded_dataa buffer containing encoded representation of a node
Returns
a node in the trie

Implemented in kagome::storage::trie::PolkadotCodec.

outcome::result<common::Buffer> kagome::storage::trie::Codec::encodeNode ( const Node node) const
inline

Encode node to byte representation.

Parameters
nodenode in the trie
Returns
encoded representation of a {
Parameters
node}

Definition at line 39 of file codec.hpp.

virtual outcome::result<common::Buffer> kagome::storage::trie::Codec::encodeNodeAndStoreChildren ( const Node node,
const StoreChildren store_children 
) const
pure virtual

Encode node to byte representation and store children.

Parameters
nodenode in the trie
store_childrenchidren storer
Returns
encoded representation of a {
Parameters
node}

Implemented in kagome::storage::trie::PolkadotCodec.

virtual common::Hash256 kagome::storage::trie::Codec::hash256 ( const common::BufferView buf) const
pure virtual

Get the hash of a node.

Parameters
bufbyte representation of the node
Returns
hash of
Parameters
buf

Implemented in kagome::storage::trie::PolkadotCodec.

virtual bool kagome::storage::trie::Codec::isMerkleHash ( const common::BufferView buf) const
pure virtual

is this a hash of value, or value itself

Implemented in kagome::storage::trie::PolkadotCodec.

virtual common::Buffer kagome::storage::trie::Codec::merkleValue ( const common::BufferView buf) const
pure virtual

Get the merkle value of a node.

Parameters
bufbyte representation of the node
Returns
hash of
Parameters
bufor
bufif it is shorter than the hash

Implemented in kagome::storage::trie::PolkadotCodec.


The documentation for this class was generated from the following file: