Kagome
Polkadot Runtime Engine in C++17
child_state_api.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_API_SERVICE_CHILD_STATE_API
7 #define KAGOME_API_SERVICE_CHILD_STATE_API
8 
9 #include <optional>
10 #include <vector>
11 
13 #include "common/buffer.hpp"
14 #include "outcome/outcome.hpp"
15 #include "primitives/block_id.hpp"
16 #include "primitives/common.hpp"
17 
18 namespace kagome::api {
19 
20  class ChildStateApi {
21  public:
22  virtual ~ChildStateApi() = default;
23 
24  virtual void setApiService(
25  const std::shared_ptr<api::ApiService> &api_service) = 0;
26 
38  virtual outcome::result<std::vector<common::Buffer>> getKeys(
39  const common::Buffer &child_storage_key,
40  const std::optional<common::Buffer> &prefix,
41  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
42 
56  virtual outcome::result<std::vector<common::Buffer>> getKeysPaged(
57  const common::Buffer &child_storage_key,
58  const std::optional<common::Buffer> &prefix,
59  uint32_t keys_amount,
60  const std::optional<common::Buffer> &prev_key_opt,
61  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
62 
71  virtual outcome::result<std::optional<common::Buffer>> getStorage(
72  const common::Buffer &child_storage_key,
73  const common::Buffer &key,
74  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
75 
84  virtual outcome::result<std::optional<primitives::BlockHash>>
86  const common::Buffer &child_storage_key,
87  const common::Buffer &key,
88  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
89 
98  virtual outcome::result<std::optional<uint64_t>> getStorageSize(
99  const common::Buffer &child_storage_key,
100  const common::Buffer &key,
101  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
102  };
103 
104 } // namespace kagome::api
105 
106 #endif // KAGOME_API_SERVICE_CHILD_STATE_API
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
virtual outcome::result< std::vector< common::Buffer > > getKeysPaged(const common::Buffer &child_storage_key, const std::optional< common::Buffer > &prefix, uint32_t keys_amount, const std::optional< common::Buffer > &prev_key_opt, const std::optional< primitives::BlockHash > &block_hash_opt) const =0
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.
virtual 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 =0
Returns a child storage entry.
virtual outcome::result< std::vector< common::Buffer > > getKeys(const common::Buffer &child_storage_key, const std::optional< common::Buffer > &prefix, const std::optional< primitives::BlockHash > &block_hash_opt) const =0
Warning: This method is UNSAFE. Returns the keys from the specified child storage. The keys can also be filtered based on a prefix.
virtual 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 =0
Returns the hash of a child storage entry.
virtual ~ChildStateApi()=default
virtual void setApiService(const std::shared_ptr< api::ApiService > &api_service)=0
virtual 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 =0
Returns the size of a child storage entry.