Skip to content

src/runtime/trie_storage_provider.hpp

Namespaces

Name
sgns
sgns::runtime

Classes

Name
class sgns::runtime::TrieStorageProvider

Source code

#ifndef SUPERGENIUS_SRC_RUNTIME_TRIE_STORAGE_PROVIDER
#define SUPERGENIUS_SRC_RUNTIME_TRIE_STORAGE_PROVIDER

#include <boost/optional.hpp>

#include "outcome/outcome.hpp"
#include "base/blob.hpp"
#include "storage/trie/trie_batches.hpp"

namespace sgns::runtime {

  class TrieStorageProvider {
   public:
    using Batch = storage::trie::TrieBatch;
    using PersistentBatch = storage::trie::PersistentTrieBatch;

    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;
  };

}  // namespace sgns::runtime

#endif  //SUPERGENIUS_SRC_RUNTIME_TRIE_STORAGE_PROVIDER

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