13 std::shared_ptr<Codec> codec, std::shared_ptr<PolkadotTrie> trie)
14 : codec_{std::move(codec)},
trie_{std::move(trie)} {
15 BOOST_ASSERT(
codec_ !=
nullptr);
16 BOOST_ASSERT(
trie_ !=
nullptr);
21 return trie_->get(key);
26 return trie_->tryGet(key);
30 return std::make_unique<PolkadotTrieCursorImpl>(
trie_);
35 return trie_->contains(key);
39 return trie_->empty();
42 outcome::result<std::tuple<bool, uint32_t>>
44 std::optional<uint64_t> limit) {
45 return trie_->clearPrefix(prefix, limit, [](
const auto &,
auto &&) {
46 return outcome::success();
52 return trie_->put(key, value);
57 return trie_->put(key, std::move(value));
61 return trie_->remove(key);
66 if (
auto root =
trie_->getRoot()) {
67 OUTCOME_TRY(encoded,
codec_->encodeNode(*root));
Class represents arbitrary (including empty) byte buffer.
std::shared_ptr< Codec > codec_
std::unique_ptr< PolkadotTrieCursor > trieCursor() override
outcome::result< BufferConstRef > get(const BufferView &key) const override
Get value by key.
outcome::result< void > remove(const BufferView &key) override
Remove value by key.
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.
std::shared_ptr< PolkadotTrie > trie_
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.
outcome::result< RootHash > hash() override
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.