Kagome
Polkadot Runtime Engine in C++17
child_state_api_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CHILD_STATE_API_IMPL_HPP
7 #define KAGOME_CHILD_STATE_API_IMPL_HPP
8 
15 
16 namespace kagome::api {
17 
18  class ChildStateApiImpl final : public ChildStateApi {
19  public:
21  std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
22  std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
23  std::shared_ptr<blockchain::BlockTree> block_tree,
24  std::shared_ptr<runtime::Core> runtime_core,
25  std::shared_ptr<runtime::Metadata> metadata);
26 
27  void setApiService(
28  const std::shared_ptr<api::ApiService> &api_service) override;
29 
30  outcome::result<std::vector<common::Buffer>> getKeys(
31  const common::Buffer &child_storage_key,
32  const std::optional<common::Buffer> &prefix_opt,
33  const std::optional<primitives::BlockHash> &block_hash_opt)
34  const override;
35 
36  outcome::result<std::vector<common::Buffer>> getKeysPaged(
37  const common::Buffer &child_storage_key,
38  const std::optional<common::Buffer> &prefix_opt,
39  uint32_t keys_amount,
40  const std::optional<common::Buffer> &prev_key_opt,
41  const std::optional<primitives::BlockHash> &block_hash_opt)
42  const override;
43 
44  outcome::result<std::optional<common::Buffer>> getStorage(
45  const common::Buffer &child_storage_key,
46  const common::Buffer &key,
47  const std::optional<primitives::BlockHash> &block_hash_opt)
48  const override;
49 
50  outcome::result<std::optional<primitives::BlockHash>> getStorageHash(
51  const common::Buffer &child_storage_key,
52  const common::Buffer &key,
53  const std::optional<primitives::BlockHash> &block_hash_opt)
54  const override;
55 
56  outcome::result<std::optional<uint64_t>> getStorageSize(
57  const common::Buffer &child_storage_key,
58  const common::Buffer &key,
59  const std::optional<primitives::BlockHash> &block_hash_opt)
60  const override;
61 
62  private:
63  std::shared_ptr<blockchain::BlockHeaderRepository> header_repo_;
64  std::shared_ptr<const storage::trie::TrieStorage> storage_;
65  std::shared_ptr<blockchain::BlockTree> block_tree_;
66  std::shared_ptr<runtime::Core> runtime_core_;
67 
68  std::weak_ptr<api::ApiService> api_service_;
69  std::shared_ptr<runtime::Metadata> metadata_;
70  };
71 
72 } // namespace kagome::api
73 
74 #endif // KAGOME_CHILD_STATE_API_IMPL_HPP
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
std::shared_ptr< blockchain::BlockTree > block_tree_
std::weak_ptr< api::ApiService > api_service_
outcome::result< std::optional< common::Buffer > > getStorage(const common::Buffer &child_storage_key, const common::Buffer &key, const std::optional< primitives::BlockHash > &block_hash_opt) const override
Returns a child storage entry.
std::shared_ptr< blockchain::BlockHeaderRepository > header_repo_
std::shared_ptr< runtime::Metadata > metadata_
ChildStateApiImpl(std::shared_ptr< blockchain::BlockHeaderRepository > block_repo, std::shared_ptr< const storage::trie::TrieStorage > trie_storage, std::shared_ptr< blockchain::BlockTree > block_tree, std::shared_ptr< runtime::Core > runtime_core, std::shared_ptr< runtime::Metadata > metadata)
std::shared_ptr< const storage::trie::TrieStorage > storage_
std::shared_ptr< runtime::Core > runtime_core_
outcome::result< std::vector< common::Buffer > > getKeysPaged(const common::Buffer &child_storage_key, const std::optional< common::Buffer > &prefix_opt, uint32_t keys_amount, const std::optional< common::Buffer > &prev_key_opt, const std::optional< primitives::BlockHash > &block_hash_opt) const override
Warning: This method is UNSAFE. Returns the keys from the specified child storage. Paginated version of getKeys. The keys can also be filtered based on a prefix.
outcome::result< std::vector< common::Buffer > > getKeys(const common::Buffer &child_storage_key, const std::optional< common::Buffer > &prefix_opt, const std::optional< primitives::BlockHash > &block_hash_opt) const override
Warning: This method is UNSAFE. Returns the keys from the specified child storage. The keys can also be filtered based on a prefix.
void setApiService(const std::shared_ptr< api::ApiService > &api_service) override
outcome::result< std::optional< primitives::BlockHash > > getStorageHash(const common::Buffer &child_storage_key, const common::Buffer &key, const std::optional< primitives::BlockHash > &block_hash_opt) const override
Returns the hash of a child storage entry.
outcome::result< std::optional< uint64_t > > getStorageSize(const common::Buffer &child_storage_key, const common::Buffer &key, const std::optional< primitives::BlockHash > &block_hash_opt) const override
Returns the size of a child storage entry.