Kagome
Polkadot Runtime Engine in C++17
trie_storage_provider.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_TRIE_STORAGE_PROVIDER
7 #define KAGOME_CORE_RUNTIME_TRIE_STORAGE_PROVIDER
8 
9 #include <optional>
10 #include <unordered_map>
11 
12 #include "common/blob.hpp"
13 #include "outcome/outcome.hpp"
15 #include "storage/trie/types.hpp"
16 
17 namespace kagome::runtime {
18 
27  public:
30 
31  virtual ~TrieStorageProvider() = default;
32 
36  virtual outcome::result<void> setToEphemeralAt(
37  const common::Hash256 &state_root) = 0;
38 
45  virtual outcome::result<void> setToPersistentAt(
46  const common::Hash256 &state_root) = 0;
47 
52  virtual std::shared_ptr<Batch> getCurrentBatch() const = 0;
53 
58  virtual std::optional<std::shared_ptr<PersistentBatch>>
59  tryGetPersistentBatch() const = 0;
60 
65  virtual bool isCurrentlyPersistent() const = 0;
66 
73  virtual outcome::result<std::shared_ptr<PersistentBatch>> getChildBatchAt(
74  const common::Buffer &root_path) = 0;
75 
79  virtual void clearChildBatches() noexcept = 0;
80 
84  virtual outcome::result<storage::trie::RootHash> forceCommit() = 0;
85 
86  // ------ Transaction methods ------
87 
89  virtual outcome::result<void> startTransaction() = 0;
90 
92  virtual outcome::result<void> rollbackTransaction() = 0;
93 
95  virtual outcome::result<void> commitTransaction() = 0;
96  };
97 
98 } // namespace kagome::runtime
99 
100 #endif // KAGOME_CORE_RUNTIME_TRIE_STORAGE_PROVIDER
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
virtual outcome::result< storage::trie::RootHash > forceCommit()=0
virtual std::optional< std::shared_ptr< PersistentBatch > > tryGetPersistentBatch() const =0
virtual outcome::result< void > commitTransaction()=0
Commit and finish last started transaction.
virtual outcome::result< void > startTransaction()=0
Start nested transaction.
virtual outcome::result< void > setToEphemeralAt(const common::Hash256 &state_root)=0
virtual bool isCurrentlyPersistent() const =0
virtual void clearChildBatches() noexcept=0
virtual outcome::result< void > setToPersistentAt(const common::Hash256 &state_root)=0
virtual std::shared_ptr< Batch > getCurrentBatch() const =0
virtual outcome::result< void > rollbackTransaction()=0
Rollback and finish last started transaction.
virtual outcome::result< std::shared_ptr< PersistentBatch > > getChildBatchAt(const common::Buffer &root_path)=0
Get (or create new) Child Batch with given root hash.
common::Hash256 RootHash
Definition: types.hpp:13