Skip to content

sgns::runtime::TrieStorageProvider

More...

#include <trie_storage_provider.hpp>

Inherited by sgns::runtime::TrieStorageProviderImpl

Public Types

Name
using storage::trie::TrieBatch Batch
using storage::trie::PersistentTrieBatch PersistentBatch

Public Functions

Name
virtual ~TrieStorageProvider() =default
virtual outcome::result< void > setToEphemeral() =0
virtual outcome::result< void > setToEphemeralAt(const base::Hash256 & state_root) =0
virtual outcome::result< void > setToPersistent() =0
virtual outcome::result< void > setToPersistentAt(const base::Hash256 & state_root) =0
virtual std::shared_ptr< Batch > getCurrentBatch() const =0
virtual boost::optional< std::shared_ptr< PersistentBatch > > tryGetPersistentBatch() const =0
virtual bool isCurrentlyPersistent() const =0
virtual outcome::result< base::Buffer > forceCommit() =0

Detailed Description

class sgns::runtime::TrieStorageProvider;

Provides access to the trie storage for runtime API As some calls need an access to a temporary storage (called 'ephemeral') and some introduce changes that need to persist, TrieStorageProvider maintains a 'current batch', which can be either persistent or ephemeral, and provides it for runtime calls

Public Types Documentation

using Batch

using sgns::runtime::TrieStorageProvider::Batch = storage::trie::TrieBatch;

using PersistentBatch

using sgns::runtime::TrieStorageProvider::PersistentBatch = storage::trie::PersistentTrieBatch;

Public Functions Documentation

function ~TrieStorageProvider

virtual ~TrieStorageProvider() =default

function setToEphemeral

virtual outcome::result< void > setToEphemeral() =0

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::setToEphemeral

Sets the current batch to a new ephemeral batch

function setToEphemeralAt

virtual outcome::result< void > setToEphemeralAt(
    const base::Hash256 & state_root
) =0

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::setToEphemeralAt

function setToPersistent

virtual outcome::result< void > setToPersistent() =0

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::setToPersistent

Sets the current batch to the persistent batch (a persistent batch is unique as it accumulates changes for commit)

function setToPersistentAt

virtual outcome::result< void > setToPersistentAt(
    const base::Hash256 & state_root
) =0

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

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::setToPersistentAt

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

function getCurrentBatch

virtual std::shared_ptr< Batch > getCurrentBatch() const =0

See: setToEphemeral, setToPersistent), null otherwise

Return: current batch, if any was set (

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::getCurrentBatch

function tryGetPersistentBatch

virtual boost::optional< std::shared_ptr< PersistentBatch > > tryGetPersistentBatch() const =0

Return: current persistent batch, if the current batch is persistent, none otherwise

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::tryGetPersistentBatch

function isCurrentlyPersistent

virtual bool isCurrentlyPersistent() const =0

Return: true, if the current batch is persistent, false otherwise

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::isCurrentlyPersistent

function forceCommit

virtual outcome::result< base::Buffer > forceCommit() =0

Reimplemented by: sgns::runtime::TrieStorageProviderImpl::forceCommit

Commits persistent changes even if the current batch is not persistent


Updated on 2026-03-04 at 13:10:43 -0800