6 #ifndef KAGOME_STORAGE_TRIE_IMPL_POLKADOT_TRIE_IMPL 7 #define KAGOME_STORAGE_TRIE_IMPL_POLKADOT_TRIE_IMPL 17 class OpaqueNodeStorage;
21 public std::enable_shared_from_this<PolkadotTrieImpl> {
44 outcome::result<ConstNodePtr>
getNode(
50 const std::function<outcome::result<void>(
51 BranchNode const &, uint8_t idx)> &callback)
const override;
56 outcome::result<std::tuple<bool, uint32_t>>
clearPrefix(
58 std::optional<uint64_t> limit,
70 outcome::result<common::BufferConstRef>
get(
73 outcome::result<std::optional<common::BufferConstRef>>
tryGet(
76 std::unique_ptr<PolkadotTrieCursor>
trieCursor()
override;
81 bool empty()
const override;
84 uint8_t idx)
const override;
86 uint8_t idx)
override;
97 std::unique_ptr<OpaqueNodeStorage>
nodes_;
106 #endif // KAGOME_STORAGE_TRIE_IMPL_POLKADOT_TRIE_IMPL outcome::result< std::tuple< bool, uint32_t > > clearPrefix(const common::BufferView &prefix, std::optional< uint64_t > limit, const OnDetachCallback &callback) override
Class represents arbitrary (including empty) byte buffer.
OUTCOME_HPP_DECLARE_ERROR(kagome::storage::trie, PolkadotTrieImpl::Error)
outcome::result< ConstNodePtr > retrieveChild(const BranchNode &parent, uint8_t idx) const override
outcome::result< void > forNodeInPath(ConstNodePtr parent, const NibblesView &path, const std::function< outcome::result< void >(BranchNode const &, uint8_t idx)> &callback) const override
outcome::result< NodePtr > updateBranch(BranchPtr parent, const NibblesView &key_nibbles, const NodePtr &node)
std::shared_ptr< TrieNode > NodePtr
outcome::result< NodePtr > insert(const NodePtr &parent, const NibblesView &key_nibbles, NodePtr node)
std::function< outcome::result< void >(const common::BufferView &key, std::optional< common::Buffer > &&value)> OnDetachCallback
PolkadotTrieImpl(PolkadotTrie::NodeRetrieveFunctor f=PolkadotTrie::defaultNodeRetrieveFunctor)
std::shared_ptr< BranchNode > BranchPtr
bool empty() const override
Returns true if the storage is empty.
std::shared_ptr< soralog::Logger > Logger
std::function< outcome::result< NodePtr >(std::shared_ptr< OpaqueTrieNode > const &)> NodeRetrieveFunctor
std::shared_ptr< const TrieNode > ConstNodePtr
outcome::result< std::optional< common::BufferConstRef > > tryGet(const common::BufferView &key) const override
Get value by key.
outcome::result< bool > contains(const common::BufferView &key) const override
Checks if given key-value binding exists in the storage.
std::unique_ptr< PolkadotTrieCursor > trieCursor() override
std::unique_ptr< OpaqueNodeStorage > nodes_
outcome::result< NodePtr > getNode(ConstNodePtr parent, const NibblesView &key_nibbles) override
NodePtr getRoot() override
static outcome::result< NodePtr > defaultNodeRetrieveFunctor(const std::shared_ptr< OpaqueTrieNode > &node)
outcome::result< void > put(const common::BufferView &key, const common::Buffer &value) override
Store value by key.