Kagome
Polkadot Runtime Engine in C++17
kagome::runtime::TrieStorageProviderImpl Class Reference

#include <trie_storage_provider_impl.hpp>

Inheritance diagram for kagome::runtime::TrieStorageProviderImpl:
Collaboration diagram for kagome::runtime::TrieStorageProviderImpl:

Public Types

enum  Error { Error::NO_BATCH = 1 }
 
- Public Types inherited from kagome::runtime::TrieStorageProvider
using Batch = storage::trie::TrieBatch
 
using PersistentBatch = storage::trie::PersistentTrieBatch
 

Public Member Functions

 TrieStorageProviderImpl (std::shared_ptr< storage::trie::TrieStorage > trie_storage, std::shared_ptr< storage::trie::TrieSerializer > trie_serializer)
 
 ~TrieStorageProviderImpl () override=default
 
outcome::result< void > setToEphemeralAt (const common::Hash256 &state_root) override
 
outcome::result< void > setToPersistentAt (const common::Hash256 &state_root) override
 
std::shared_ptr< BatchgetCurrentBatch () const override
 
std::optional< std::shared_ptr< PersistentBatch > > tryGetPersistentBatch () const override
 
bool isCurrentlyPersistent () const override
 
outcome::result< std::shared_ptr< PersistentBatch > > getChildBatchAt (const common::Buffer &root_path) override
 Get (or create new) Child Batch with given root hash. More...
 
outcome::result< storage::trie::RootHashforceCommit () override
 
outcome::result< void > startTransaction () override
 Start nested transaction. More...
 
outcome::result< void > rollbackTransaction () override
 Rollback and finish last started transaction. More...
 
outcome::result< void > commitTransaction () override
 Commit and finish last started transaction. More...
 
void clearChildBatches () noexceptoverride
 
- Public Member Functions inherited from kagome::runtime::TrieStorageProvider
virtual ~TrieStorageProvider ()=default
 

Private Attributes

std::shared_ptr< storage::trie::TrieStoragetrie_storage_
 
std::shared_ptr< storage::trie::TrieSerializertrie_serializer_
 
std::stack< std::shared_ptr< Batch > > stack_of_batches_
 
std::shared_ptr< Batchcurrent_batch_
 
std::shared_ptr< PersistentBatchpersistent_batch_
 
std::unordered_map< common::Buffer, std::shared_ptr< PersistentBatch > > child_batches_
 
log::Logger logger_
 

Detailed Description

Definition at line 22 of file trie_storage_provider_impl.hpp.

Member Enumeration Documentation

Enumerator
NO_BATCH 

Definition at line 24 of file trie_storage_provider_impl.hpp.

Constructor & Destructor Documentation

kagome::runtime::TrieStorageProviderImpl::TrieStorageProviderImpl ( std::shared_ptr< storage::trie::TrieStorage trie_storage,
std::shared_ptr< storage::trie::TrieSerializer trie_serializer 
)
explicit

Definition at line 29 of file trie_storage_provider_impl.cpp.

kagome::runtime::TrieStorageProviderImpl::~TrieStorageProviderImpl ( )
overridedefault

Member Function Documentation

void kagome::runtime::TrieStorageProviderImpl::clearChildBatches ( )
overridevirtualnoexcept

Clear internal map of child storages batches

Implements kagome::runtime::TrieStorageProvider.

Definition at line 97 of file trie_storage_provider_impl.cpp.

outcome::result< void > kagome::runtime::TrieStorageProviderImpl::commitTransaction ( )
overridevirtual

Commit and finish last started transaction.

Implements kagome::runtime::TrieStorageProvider.

Definition at line 141 of file trie_storage_provider_impl.cpp.

outcome::result< storage::trie::RootHash > kagome::runtime::TrieStorageProviderImpl::forceCommit ( )
overridevirtual

Commits persistent changes even if the current batch is not persistent

Implements kagome::runtime::TrieStorageProvider.

Definition at line 102 of file trie_storage_provider_impl.cpp.

outcome::result< std::shared_ptr< TrieStorageProvider::PersistentBatch > > kagome::runtime::TrieStorageProviderImpl::getChildBatchAt ( const common::Buffer root_path)
overridevirtual

Get (or create new) Child Batch with given root hash.

Parameters
rootroot hash value of a new (or cached) batch
Returns
Child storage tree batch

Implements kagome::runtime::TrieStorageProvider.

Definition at line 76 of file trie_storage_provider_impl.cpp.

std::shared_ptr< TrieStorageProviderImpl::Batch > kagome::runtime::TrieStorageProviderImpl::getCurrentBatch ( ) const
overridevirtual
Returns
current batch, if any was set (
See also
setToEphemeral, setToPersistent), null otherwise

Implements kagome::runtime::TrieStorageProvider.

Definition at line 60 of file trie_storage_provider_impl.cpp.

bool kagome::runtime::TrieStorageProviderImpl::isCurrentlyPersistent ( ) const
overridevirtual
Returns
true, if the current batch is persistent, false otherwise

Implements kagome::runtime::TrieStorageProvider.

Definition at line 70 of file trie_storage_provider_impl.cpp.

outcome::result< void > kagome::runtime::TrieStorageProviderImpl::rollbackTransaction ( )
overridevirtual

Rollback and finish last started transaction.

Implements kagome::runtime::TrieStorageProvider.

Definition at line 128 of file trie_storage_provider_impl.cpp.

outcome::result< void > kagome::runtime::TrieStorageProviderImpl::setToEphemeralAt ( const common::Hash256 state_root)
overridevirtual

Sets the current batch to a new ephemeral batch

Implements kagome::runtime::TrieStorageProvider.

Definition at line 38 of file trie_storage_provider_impl.cpp.

outcome::result< void > kagome::runtime::TrieStorageProviderImpl::setToPersistentAt ( const common::Hash256 state_root)
overridevirtual

Sets the current batch to a new persistent batch at specified storage state

Warning
this will reset storage state to th specified root and discard all changes accumulated in the current persistent batch

Implements kagome::runtime::TrieStorageProvider.

Definition at line 48 of file trie_storage_provider_impl.cpp.

outcome::result< void > kagome::runtime::TrieStorageProviderImpl::startTransaction ( )
overridevirtual

Start nested transaction.

Implements kagome::runtime::TrieStorageProvider.

Definition at line 118 of file trie_storage_provider_impl.cpp.

std::optional< std::shared_ptr< TrieStorageProviderImpl::PersistentBatch > > kagome::runtime::TrieStorageProviderImpl::tryGetPersistentBatch ( ) const
overridevirtual
Returns
current persistent batch, if the current batch is persistent, none otherwise

Implements kagome::runtime::TrieStorageProvider.

Definition at line 65 of file trie_storage_provider_impl.cpp.

Member Data Documentation

std::unordered_map<common::Buffer, std::shared_ptr<PersistentBatch> > kagome::runtime::TrieStorageProviderImpl::child_batches_
private

Definition at line 69 of file trie_storage_provider_impl.hpp.

std::shared_ptr<Batch> kagome::runtime::TrieStorageProviderImpl::current_batch_
private

Definition at line 62 of file trie_storage_provider_impl.hpp.

log::Logger kagome::runtime::TrieStorageProviderImpl::logger_
private

Definition at line 71 of file trie_storage_provider_impl.hpp.

std::shared_ptr<PersistentBatch> kagome::runtime::TrieStorageProviderImpl::persistent_batch_
private

Definition at line 66 of file trie_storage_provider_impl.hpp.

std::stack<std::shared_ptr<Batch> > kagome::runtime::TrieStorageProviderImpl::stack_of_batches_
private

Definition at line 60 of file trie_storage_provider_impl.hpp.

std::shared_ptr<storage::trie::TrieSerializer> kagome::runtime::TrieStorageProviderImpl::trie_serializer_
private

Definition at line 58 of file trie_storage_provider_impl.hpp.

std::shared_ptr<storage::trie::TrieStorage> kagome::runtime::TrieStorageProviderImpl::trie_storage_
private

Definition at line 57 of file trie_storage_provider_impl.hpp.


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