Kagome
Polkadot Runtime Engine in C++17
trie_storage_backend_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_BACKEND
7 #define KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_BACKEND
8 
9 #include "common/buffer.hpp"
10 #include "outcome/outcome.hpp"
12 
13 namespace kagome::storage::trie {
14 
16  public:
17  TrieStorageBackendImpl(std::shared_ptr<BufferStorage> storage,
18  common::Buffer node_prefix);
19 
20  ~TrieStorageBackendImpl() override = default;
21 
22  std::unique_ptr<Cursor> cursor() override;
23  std::unique_ptr<face::WriteBatch<BufferView, Buffer>> batch() override;
24 
25  outcome::result<Buffer> load(const BufferView &key) const override;
26  outcome::result<std::optional<Buffer>> tryLoad(
27  const BufferView &key) const override;
28  outcome::result<bool> contains(const BufferView &key) const override;
29  bool empty() const override;
30 
31  outcome::result<void> put(const BufferView &key,
32  const Buffer &value) override;
33  outcome::result<void> put(const BufferView &key, Buffer &&value) override;
34  outcome::result<void> remove(const common::BufferView &key) override;
35 
36  size_t size() const override;
37 
38  private:
40 
41  std::shared_ptr<BufferStorage> storage_;
43  };
44 
45 } // namespace kagome::storage::trie
46 
47 #endif // KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_BACKEND
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
outcome::result< bool > contains(const BufferView &key) const override
outcome::result< Buffer > load(const BufferView &key) const override
std::unique_ptr< face::WriteBatch< BufferView, Buffer > > batch() override
Creates new Write Batch - an object, which can be used to efficiently write bulk data.
TrieStorageBackendImpl(std::shared_ptr< BufferStorage > storage, common::Buffer node_prefix)
common::Buffer prefixKey(const common::BufferView &key) const
outcome::result< void > put(const BufferView &key, const Buffer &value) override
std::unique_ptr< Cursor > cursor() override
Returns new key-value iterator.
outcome::result< std::optional< Buffer > > tryLoad(const BufferView &key) const override
bool empty() const override
Returns true if the storage is empty.