Kagome
Polkadot Runtime Engine in C++17
trie_serializer_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STORAGE_TRIE_SERIALIZER_IMPL
7 #define KAGOME_STORAGE_TRIE_SERIALIZER_IMPL
8 
10 
12 
13 namespace kagome::storage::trie {
14  class Codec;
15  class PolkadotTrieFactory;
16  class TrieStorageBackend;
17  struct BranchNode;
18  struct TrieNode;
19 } // namespace kagome::storage::trie
20 
21 namespace kagome::storage::trie {
22 
24  public:
25  TrieSerializerImpl(std::shared_ptr<PolkadotTrieFactory> factory,
26  std::shared_ptr<Codec> codec,
27  std::shared_ptr<TrieStorageBackend> backend);
28  ~TrieSerializerImpl() override = default;
29 
30  RootHash getEmptyRootHash() const override;
31 
32  outcome::result<RootHash> storeTrie(PolkadotTrie &trie) override;
33 
34  outcome::result<std::shared_ptr<PolkadotTrie>> retrieveTrie(
35  const common::Buffer &db_key) const override;
36 
37  private:
43  outcome::result<RootHash> storeRootNode(TrieNode &node);
49  outcome::result<PolkadotTrie::NodePtr> retrieveNode(
50  const common::Buffer &db_key) const;
55  outcome::result<PolkadotTrie::NodePtr> retrieveNode(
56  const std::shared_ptr<OpaqueTrieNode> &node) const;
57 
58  std::shared_ptr<PolkadotTrieFactory> trie_factory_;
59  std::shared_ptr<Codec> codec_;
60  std::shared_ptr<TrieStorageBackend> backend_;
61  };
62 } // namespace kagome::storage::trie
63 
64 #endif // KAGOME_STORAGE_TRIE_SERIALIZER_IMPL
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
std::shared_ptr< PolkadotTrieFactory > trie_factory_
outcome::result< RootHash > storeTrie(PolkadotTrie &trie) override
TrieSerializerImpl(std::shared_ptr< PolkadotTrieFactory > factory, std::shared_ptr< Codec > codec, std::shared_ptr< TrieStorageBackend > backend)
outcome::result< std::shared_ptr< PolkadotTrie > > retrieveTrie(const common::Buffer &db_key) const override
std::shared_ptr< TrieStorageBackend > backend_
outcome::result< PolkadotTrie::NodePtr > retrieveNode(const common::Buffer &db_key) const
outcome::result< RootHash > storeRootNode(TrieNode &node)