Kagome
Polkadot Runtime Engine in C++17
ephemeral_trie_batch_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STORAGE_TRIE_IMPL_EPHEMERAL_TRIE_BATCH
7 #define KAGOME_STORAGE_TRIE_IMPL_EPHEMERAL_TRIE_BATCH
8 
9 #include "storage/trie/codec.hpp"
12 
13 namespace kagome::storage::trie {
14 
16  public:
17  EphemeralTrieBatchImpl(std::shared_ptr<Codec> codec,
18  std::shared_ptr<PolkadotTrie> trie);
19  ~EphemeralTrieBatchImpl() override = default;
20 
21  outcome::result<BufferConstRef> get(const BufferView &key) const override;
22  outcome::result<std::optional<BufferConstRef>> tryGet(
23  const BufferView &key) const override;
24  std::unique_ptr<PolkadotTrieCursor> trieCursor() override;
25  outcome::result<bool> contains(const BufferView &key) const override;
26  bool empty() const override;
27  outcome::result<std::tuple<bool, uint32_t>> clearPrefix(
28  const BufferView &prefix,
29  std::optional<uint64_t> limit = std::nullopt) override;
30  outcome::result<void> put(const BufferView &key,
31  const Buffer &value) override;
32  outcome::result<void> put(const BufferView &key, Buffer &&value) override;
33  outcome::result<void> remove(const BufferView &key) override;
34  outcome::result<RootHash> hash() override;
35 
36  private:
37  std::shared_ptr<Codec> codec_;
38  std::shared_ptr<PolkadotTrie> trie_;
39  };
40 
41 } // namespace kagome::storage::trie
42 
43 #endif // KAGOME_STORAGE_TRIE_IMPL_EPHEMERAL_TRIE_BATCH
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
std::unique_ptr< PolkadotTrieCursor > trieCursor() override
bool empty() const override
Returns true if the storage is empty.
outcome::result< void > put(const BufferView &key, const Buffer &value) override
Store value by key.
outcome::result< std::tuple< bool, uint32_t > > clearPrefix(const BufferView &prefix, std::optional< uint64_t > limit=std::nullopt) override
outcome::result< std::optional< BufferConstRef > > tryGet(const BufferView &key) const override
Get value by key.
EphemeralTrieBatchImpl(std::shared_ptr< Codec > codec, std::shared_ptr< PolkadotTrie > trie)
outcome::result< bool > contains(const BufferView &key) const override
Checks if given key-value binding exists in the storage.