Kagome
Polkadot Runtime Engine in C++17
kagome::storage::trie::PersistentTrieBatchImpl Class Referencefinal

#include <persistent_trie_batch_impl.hpp>

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

Public Types

enum  Error { Error::NO_TRIE = 1 }
 
- Public Types inherited from kagome::storage::trie::TrieBatch
using Cursor = face::Iterable< Buffer, common::BufferConstRef, BufferView >::Cursor
 
- Public Types inherited from kagome::storage::face::ReadableMap< BufferView, Buffer >
using Key = BufferView
 
using Value = Buffer
 
using ValueView = std::reference_wrapper< Buffer >
 
using ConstValueView = std::reference_wrapper< const Buffer >
 
- Public Types inherited from kagome::storage::face::ReadableBase< BufferView >
using Key = BufferView
 
- Public Types inherited from kagome::storage::face::Iterable< Buffer, common::BufferConstRef, BufferView >
using Cursor = MapCursor< Buffer, common::BufferConstRef, BufferView >
 

Public Member Functions

 ~PersistentTrieBatchImpl () override=default
 
outcome::result< RootHashcommit () override
 
std::unique_ptr< TopperTrieBatchbatchOnTop () override
 
outcome::result< BufferConstRefget (const BufferView &key) const override
 Get value by key. More...
 
outcome::result< std::optional< BufferConstRef > > tryGet (const BufferView &key) const override
 Get value by key. More...
 
std::unique_ptr< PolkadotTrieCursortrieCursor () override
 
outcome::result< bool > contains (const BufferView &key) const override
 Checks if given key-value binding exists in the storage. More...
 
bool empty () const override
 Returns true if the storage is empty. More...
 
outcome::result< std::tuple< bool, uint32_t > > clearPrefix (const BufferView &prefix, std::optional< uint64_t > limit=std::nullopt) override
 
outcome::result< void > put (const BufferView &key, const Buffer &value) override
 Store value by key. More...
 
outcome::result< void > put (const BufferView &key, Buffer &&value) override
 
outcome::result< void > remove (const BufferView &key) override
 Remove value by key. More...
 
- Public Member Functions inherited from kagome::storage::trie::TrieBatch
 ~TrieBatch () override=default
 
std::unique_ptr< Cursorcursor () final
 Returns new key-value iterator. More...
 
- Public Member Functions inherited from kagome::storage::face::ReadableMap< BufferView, Buffer >
virtual ~ReadableMap ()=default
 
- Public Member Functions inherited from kagome::storage::face::ReadableBase< BufferView >
virtual ~ReadableBase ()=default
 
- Public Member Functions inherited from kagome::storage::face::Writeable< BufferView, Buffer >
virtual ~Writeable ()=default
 
- Public Member Functions inherited from kagome::storage::face::Iterable< Buffer, common::BufferConstRef, BufferView >
virtual ~Iterable ()=default
 

Static Public Member Functions

static std::unique_ptr< PersistentTrieBatchImplcreate (std::shared_ptr< Codec > codec, std::shared_ptr< TrieSerializer > serializer, std::optional< std::shared_ptr< changes_trie::ChangesTracker >> changes, std::shared_ptr< PolkadotTrie > trie)
 

Private Member Functions

 PersistentTrieBatchImpl (std::shared_ptr< Codec > codec, std::shared_ptr< TrieSerializer > serializer, std::optional< std::shared_ptr< changes_trie::ChangesTracker >> changes, std::shared_ptr< PolkadotTrie > trie)
 

Private Attributes

std::shared_ptr< Codeccodec_
 
std::shared_ptr< TrieSerializerserializer_
 
std::optional< std::shared_ptr< changes_trie::ChangesTracker > > changes_
 
std::shared_ptr< PolkadotTrietrie_
 
log::Logger logger_ = log::createLogger("PersistentTrieBatch", "storage")
 

Detailed Description

Definition at line 20 of file persistent_trie_batch_impl.hpp.

Member Enumeration Documentation

Enumerator
NO_TRIE 

Definition at line 22 of file persistent_trie_batch_impl.hpp.

Constructor & Destructor Documentation

kagome::storage::trie::PersistentTrieBatchImpl::~PersistentTrieBatchImpl ( )
overridedefault
kagome::storage::trie::PersistentTrieBatchImpl::PersistentTrieBatchImpl ( std::shared_ptr< Codec codec,
std::shared_ptr< TrieSerializer serializer,
std::optional< std::shared_ptr< changes_trie::ChangesTracker >>  changes,
std::shared_ptr< PolkadotTrie trie 
)
private

Definition at line 39 of file persistent_trie_batch_impl.cpp.

Member Function Documentation

std::unique_ptr< TopperTrieBatch > kagome::storage::trie::PersistentTrieBatchImpl::batchOnTop ( )
overridevirtual

Creates a batch on top of this batch

Implements kagome::storage::trie::PersistentTrieBatch.

Definition at line 61 of file persistent_trie_batch_impl.cpp.

outcome::result< std::tuple< bool, uint32_t > > kagome::storage::trie::PersistentTrieBatchImpl::clearPrefix ( const BufferView prefix,
std::optional< uint64_t >  limit = std::nullopt 
)
overridevirtual

Remove all trie entries which key begins with the supplied prefix

Implements kagome::storage::trie::TrieBatch.

Definition at line 89 of file persistent_trie_batch_impl.cpp.

outcome::result< RootHash > kagome::storage::trie::PersistentTrieBatchImpl::commit ( )
overridevirtual

Commits changes to a persistent storage

Returns
the root of the committed trie

Implements kagome::storage::trie::PersistentTrieBatch.

Definition at line 55 of file persistent_trie_batch_impl.cpp.

outcome::result< bool > kagome::storage::trie::PersistentTrieBatchImpl::contains ( const BufferView key) const
overridevirtual

Checks if given key-value binding exists in the storage.

Parameters
keyK
Returns
true if key has value, false if does not, or error at .

Implements kagome::storage::face::ReadableBase< BufferView >.

Definition at line 79 of file persistent_trie_batch_impl.cpp.

std::unique_ptr< PersistentTrieBatchImpl > kagome::storage::trie::PersistentTrieBatchImpl::create ( std::shared_ptr< Codec codec,
std::shared_ptr< TrieSerializer serializer,
std::optional< std::shared_ptr< changes_trie::ChangesTracker >>  changes,
std::shared_ptr< PolkadotTrie trie 
)
static

Definition at line 26 of file persistent_trie_batch_impl.cpp.

bool kagome::storage::trie::PersistentTrieBatchImpl::empty ( ) const
overridevirtual

Returns true if the storage is empty.

Implements kagome::storage::face::ReadableBase< BufferView >.

Definition at line 84 of file persistent_trie_batch_impl.cpp.

outcome::result< BufferConstRef > kagome::storage::trie::PersistentTrieBatchImpl::get ( const BufferView key) const
overridevirtual

Get value by key.

Parameters
keyK
Returns
V

Implements kagome::storage::face::ReadableMap< BufferView, Buffer >.

Definition at line 65 of file persistent_trie_batch_impl.cpp.

outcome::result< void > kagome::storage::trie::PersistentTrieBatchImpl::put ( const BufferView key,
const Buffer value 
)
overridevirtual

Store value by key.

Parameters
keykey
valuevalue
Returns
result containing void if put successful, error otherwise

Implements kagome::storage::face::Writeable< BufferView, Buffer >.

Definition at line 101 of file persistent_trie_batch_impl.cpp.

outcome::result< void > kagome::storage::trie::PersistentTrieBatchImpl::put ( const BufferView key,
Buffer &&  value 
)
overridevirtual
outcome::result< void > kagome::storage::trie::PersistentTrieBatchImpl::remove ( const BufferView key)
overridevirtual

Remove value by key.

Parameters
keyK
Returns
error code if error happened

Implements kagome::storage::face::Writeable< BufferView, Buffer >.

Definition at line 120 of file persistent_trie_batch_impl.cpp.

std::unique_ptr< PolkadotTrieCursor > kagome::storage::trie::PersistentTrieBatchImpl::trieCursor ( )
overridevirtual

Implements kagome::storage::trie::TrieBatch.

Definition at line 75 of file persistent_trie_batch_impl.cpp.

outcome::result< std::optional< BufferConstRef > > kagome::storage::trie::PersistentTrieBatchImpl::tryGet ( const BufferView key) const
overridevirtual

Get value by key.

Parameters
keyK
Returns
V if contains(K) or std::nullopt

Implements kagome::storage::face::ReadableMap< BufferView, Buffer >.

Definition at line 71 of file persistent_trie_batch_impl.cpp.

Member Data Documentation

std::optional<std::shared_ptr<changes_trie::ChangesTracker> > kagome::storage::trie::PersistentTrieBatchImpl::changes_
private

Definition at line 59 of file persistent_trie_batch_impl.hpp.

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

Definition at line 57 of file persistent_trie_batch_impl.hpp.

log::Logger kagome::storage::trie::PersistentTrieBatchImpl::logger_ = log::createLogger("PersistentTrieBatch", "storage")
private

Definition at line 62 of file persistent_trie_batch_impl.hpp.

std::shared_ptr<TrieSerializer> kagome::storage::trie::PersistentTrieBatchImpl::serializer_
private

Definition at line 58 of file persistent_trie_batch_impl.hpp.

std::shared_ptr<PolkadotTrie> kagome::storage::trie::PersistentTrieBatchImpl::trie_
private

Definition at line 60 of file persistent_trie_batch_impl.hpp.


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