Kagome
Polkadot Runtime Engine in C++17
trie_storage_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_IMPL
7 #define KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_IMPL
8 
10 
11 #include "log/logger.hpp"
14 #include "storage/trie/codec.hpp"
17 
18 namespace kagome::storage::trie {
19 
20  class TrieStorageImpl : public TrieStorage {
21  public:
22  static outcome::result<std::unique_ptr<TrieStorageImpl>> createEmpty(
23  const std::shared_ptr<PolkadotTrieFactory> &trie_factory,
24  std::shared_ptr<Codec> codec,
25  std::shared_ptr<TrieSerializer> serializer,
26  std::optional<std::shared_ptr<changes_trie::ChangesTracker>> changes);
27 
28  static outcome::result<std::unique_ptr<TrieStorageImpl>> createFromStorage(
29  std::shared_ptr<Codec> codec,
30  std::shared_ptr<TrieSerializer> serializer,
31  std::optional<std::shared_ptr<changes_trie::ChangesTracker>> changes);
32 
33  TrieStorageImpl(TrieStorageImpl const &) = delete;
34  void operator=(const TrieStorageImpl &) = delete;
35 
36  TrieStorageImpl(TrieStorageImpl &&) = default;
38  ~TrieStorageImpl() override = default;
39 
40  outcome::result<std::unique_ptr<PersistentTrieBatch>> getPersistentBatchAt(
41  const RootHash &root) override;
42  outcome::result<std::unique_ptr<EphemeralTrieBatch>> getEphemeralBatchAt(
43  const RootHash &root) const override;
44 
45  protected:
47  std::shared_ptr<Codec> codec,
48  std::shared_ptr<TrieSerializer> serializer,
49  std::optional<std::shared_ptr<changes_trie::ChangesTracker>> changes);
50 
51  private:
52  std::shared_ptr<Codec> codec_;
53  std::shared_ptr<TrieSerializer> serializer_;
54  std::optional<std::shared_ptr<changes_trie::ChangesTracker>> changes_;
56  };
57 
58 } // namespace kagome::storage::trie
59 
60 #endif // KAGOME_STORAGE_TRIE_IMPL_TRIE_STORAGE_IMPL
TrieStorageImpl(TrieStorageImpl const &)=delete
static outcome::result< std::unique_ptr< TrieStorageImpl > > createFromStorage(std::shared_ptr< Codec > codec, std::shared_ptr< TrieSerializer > serializer, std::optional< std::shared_ptr< changes_trie::ChangesTracker >> changes)
std::shared_ptr< TrieSerializer > serializer_
outcome::result< std::unique_ptr< EphemeralTrieBatch > > getEphemeralBatchAt(const RootHash &root) const override
void operator=(const TrieStorageImpl &)=delete
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
outcome::result< std::unique_ptr< PersistentTrieBatch > > getPersistentBatchAt(const RootHash &root) override
static outcome::result< std::unique_ptr< TrieStorageImpl > > createEmpty(const std::shared_ptr< PolkadotTrieFactory > &trie_factory, std::shared_ptr< Codec > codec, std::shared_ptr< TrieSerializer > serializer, std::optional< std::shared_ptr< changes_trie::ChangesTracker >> changes)
std::optional< std::shared_ptr< changes_trie::ChangesTracker > > changes_