Kagome
Polkadot Runtime Engine in C++17
kagome::storage::trie::TrieSerializerImpl Class Reference

#include <trie_serializer_impl.hpp>

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

Public Member Functions

 TrieSerializerImpl (std::shared_ptr< PolkadotTrieFactory > factory, std::shared_ptr< Codec > codec, std::shared_ptr< TrieStorageBackend > backend)
 
 ~TrieSerializerImpl () override=default
 
RootHash getEmptyRootHash () const override
 
outcome::result< RootHashstoreTrie (PolkadotTrie &trie) override
 
outcome::result< std::shared_ptr< PolkadotTrie > > retrieveTrie (const common::Buffer &db_key) const override
 
- Public Member Functions inherited from kagome::storage::trie::TrieSerializer
virtual ~TrieSerializer ()=default
 

Private Member Functions

outcome::result< RootHashstoreRootNode (TrieNode &node)
 
outcome::result< PolkadotTrie::NodePtrretrieveNode (const common::Buffer &db_key) const
 
outcome::result< PolkadotTrie::NodePtrretrieveNode (const std::shared_ptr< OpaqueTrieNode > &node) const
 

Private Attributes

std::shared_ptr< PolkadotTrieFactorytrie_factory_
 
std::shared_ptr< Codeccodec_
 
std::shared_ptr< TrieStorageBackendbackend_
 

Detailed Description

Definition at line 23 of file trie_serializer_impl.hpp.

Constructor & Destructor Documentation

kagome::storage::trie::TrieSerializerImpl::TrieSerializerImpl ( std::shared_ptr< PolkadotTrieFactory factory,
std::shared_ptr< Codec codec,
std::shared_ptr< TrieStorageBackend backend 
)

Definition at line 15 of file trie_serializer_impl.cpp.

kagome::storage::trie::TrieSerializerImpl::~TrieSerializerImpl ( )
overridedefault

Member Function Documentation

RootHash kagome::storage::trie::TrieSerializerImpl::getEmptyRootHash ( ) const
overridevirtual
Returns
root hash of an empty trie

Implements kagome::storage::trie::TrieSerializer.

Definition at line 27 of file trie_serializer_impl.cpp.

outcome::result< PolkadotTrie::NodePtr > kagome::storage::trie::TrieSerializerImpl::retrieveNode ( const common::Buffer db_key) const
private

Fetches a node from the storage. A nullptr is returned in case that there is no entry for provided key. Mind that a branch node will have dummy nodes as its children

Definition at line 79 of file trie_serializer_impl.cpp.

outcome::result< PolkadotTrie::NodePtr > kagome::storage::trie::TrieSerializerImpl::retrieveNode ( const std::shared_ptr< OpaqueTrieNode > &  node) const
private

Retrieves a node, replacing a dummy node to an actual node if needed

Definition at line 70 of file trie_serializer_impl.cpp.

outcome::result< std::shared_ptr< PolkadotTrie > > kagome::storage::trie::TrieSerializerImpl::retrieveTrie ( const common::Buffer db_key) const
overridevirtual

Fetches a trie from the storage. A nullptr is returned in case that there is no entry for provided key.

Implements kagome::storage::trie::TrieSerializer.

Definition at line 40 of file trie_serializer_impl.cpp.

outcome::result< RootHash > kagome::storage::trie::TrieSerializerImpl::storeRootNode ( TrieNode node)
private

Writes a node to a persistent storage, recursively storing its descendants as well. Then replaces the node children to dummy nodes to avoid memory waste

Definition at line 54 of file trie_serializer_impl.cpp.

outcome::result< RootHash > kagome::storage::trie::TrieSerializerImpl::storeTrie ( PolkadotTrie trie)
overridevirtual

Writes a trie to a storage, recursively storing its nodes.

Implements kagome::storage::trie::TrieSerializer.

Definition at line 32 of file trie_serializer_impl.cpp.

Member Data Documentation

std::shared_ptr<TrieStorageBackend> kagome::storage::trie::TrieSerializerImpl::backend_
private

Definition at line 60 of file trie_serializer_impl.hpp.

std::shared_ptr<Codec> kagome::storage::trie::TrieSerializerImpl::codec_
private

Definition at line 59 of file trie_serializer_impl.hpp.

std::shared_ptr<PolkadotTrieFactory> kagome::storage::trie::TrieSerializerImpl::trie_factory_
private

Definition at line 58 of file trie_serializer_impl.hpp.


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