Kagome
Polkadot Runtime Engine in C++17
state_api.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_API_SERVICE_STATE_API
7 #define KAGOME_API_SERVICE_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 #include "primitives/version.hpp"
18 
19 namespace kagome::api {
20 
21  class StateApi {
22  public:
23  virtual ~StateApi() = default;
24 
25  virtual void setApiService(
26  const std::shared_ptr<api::ApiService> &api_service) = 0;
27 
28  virtual outcome::result<common::Buffer> call(
29  std::string_view method,
30  common::Buffer data,
31  const std::optional<primitives::BlockHash> &opt_at) const = 0;
32 
33  virtual outcome::result<std::vector<common::Buffer>> getKeysPaged(
34  const std::optional<common::BufferView> &prefix,
35  uint32_t keys_amount,
36  const std::optional<common::BufferView> &prev_key,
37  const std::optional<primitives::BlockHash> &block_hash_opt) const = 0;
38 
39  virtual outcome::result<std::optional<common::Buffer>> getStorage(
40  const common::BufferView &key) const = 0;
41  virtual outcome::result<std::optional<common::Buffer>> getStorageAt(
42  const common::BufferView &key,
43  const primitives::BlockHash &at) const = 0;
44 
47  struct Change {
49  std::optional<common::Buffer> data;
50  };
51  std::vector<Change> changes;
52  };
53 
54  virtual outcome::result<std::vector<StorageChangeSet>> queryStorage(
55  gsl::span<const common::Buffer> keys,
56  const primitives::BlockHash &from,
57  std::optional<primitives::BlockHash> to) const = 0;
58 
59  virtual outcome::result<std::vector<StorageChangeSet>> queryStorageAt(
60  gsl::span<const common::Buffer> keys,
61  std::optional<primitives::BlockHash> at) const = 0;
62 
63  virtual outcome::result<uint32_t> subscribeStorage(
64  const std::vector<common::Buffer> &keys) = 0;
65  virtual outcome::result<bool> unsubscribeStorage(
66  const std::vector<uint32_t> &subscription_id) = 0;
67 
68  virtual outcome::result<primitives::Version> getRuntimeVersion(
69  const std::optional<primitives::BlockHash> &at) const = 0;
70 
71  virtual outcome::result<uint32_t> subscribeRuntimeVersion() = 0;
72  virtual outcome::result<void> unsubscribeRuntimeVersion(
73  uint32_t subscription_id) = 0;
74  virtual outcome::result<std::string> getMetadata() = 0;
75 
76  virtual outcome::result<std::string> getMetadata(
77  std::string_view hex_block_hash) = 0;
78  };
79 
80 } // namespace kagome::api
81 
82 #endif // KAGOME_API_SERVICE_STATE_API
virtual outcome::result< std::optional< common::Buffer > > getStorageAt(const common::BufferView &key, const primitives::BlockHash &at) const =0
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
virtual outcome::result< common::Buffer > call(std::string_view method, common::Buffer data, const std::optional< primitives::BlockHash > &opt_at) const =0
virtual outcome::result< std::vector< StorageChangeSet > > queryStorage(gsl::span< const common::Buffer > keys, const primitives::BlockHash &from, std::optional< primitives::BlockHash > to) const =0
virtual outcome::result< std::optional< common::Buffer > > getStorage(const common::BufferView &key) const =0
virtual outcome::result< std::vector< StorageChangeSet > > queryStorageAt(gsl::span< const common::Buffer > keys, std::optional< primitives::BlockHash > at) const =0
virtual ~StateApi()=default
virtual outcome::result< std::vector< common::Buffer > > getKeysPaged(const std::optional< common::BufferView > &prefix, uint32_t keys_amount, const std::optional< common::BufferView > &prev_key, const std::optional< primitives::BlockHash > &block_hash_opt) const =0
virtual outcome::result< bool > unsubscribeStorage(const std::vector< uint32_t > &subscription_id)=0
std::optional< common::Buffer > data
Definition: state_api.hpp:49
virtual outcome::result< void > unsubscribeRuntimeVersion(uint32_t subscription_id)=0
virtual outcome::result< primitives::Version > getRuntimeVersion(const std::optional< primitives::BlockHash > &at) const =0
virtual void setApiService(const std::shared_ptr< api::ApiService > &api_service)=0
virtual outcome::result< uint32_t > subscribeStorage(const std::vector< common::Buffer > &keys)=0
virtual outcome::result< uint32_t > subscribeRuntimeVersion()=0
virtual outcome::result< std::string > getMetadata()=0