Kagome
Polkadot Runtime Engine in C++17
chain_api.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_API_CHAIN_API_HPP
7 #define KAGOME_API_CHAIN_API_HPP
8 
9 #include <boost/variant.hpp>
10 
11 #include "common/buffer.hpp"
12 #include "outcome/outcome.hpp"
15 #include "primitives/common.hpp"
16 
17 namespace kagome::api {
18  class ApiService;
19 
23  class ChainApi {
24  public:
25  virtual ~ChainApi() = default;
28  using ValueType = boost::variant<BlockNumber, std::string>;
29 
30  virtual void setApiService(
31  const std::shared_ptr<api::ApiService> &api_service) = 0;
32 
36  virtual outcome::result<BlockHash> getBlockHash() const = 0;
37 
42  virtual outcome::result<BlockHash> getBlockHash(
43  BlockNumber block_number) const = 0;
44 
49  virtual outcome::result<BlockHash> getBlockHash(
50  std::string_view hex_number) const = 0;
51 
57  virtual outcome::result<std::vector<BlockHash>> getBlockHash(
58  gsl::span<const ValueType> values) const = 0;
59 
63  virtual outcome::result<primitives::BlockHeader> getHeader(
64  std::string_view hash) = 0;
65 
69  virtual outcome::result<primitives::BlockHeader> getHeader() = 0;
70 
74  virtual outcome::result<primitives::BlockData> getBlock(
75  std::string_view hash) = 0;
76 
80  virtual outcome::result<primitives::BlockData> getBlock() = 0;
81 
86  virtual outcome::result<primitives::BlockHash> getFinalizedHead() const = 0;
87 
92  virtual outcome::result<uint32_t> subscribeFinalizedHeads() = 0;
93 
97  virtual outcome::result<void> unsubscribeFinalizedHeads(
98  uint32_t subscription_id) = 0;
99 
104  virtual outcome::result<uint32_t> subscribeNewHeads() = 0;
105 
109  virtual outcome::result<void> unsubscribeNewHeads(
110  uint32_t subscription_id) = 0;
111  };
112 
113 } // namespace kagome::api
114 
115 #endif // KAGOME_API_CHAIN_API_HPP
virtual ~ChainApi()=default
virtual outcome::result< primitives::BlockData > getBlock()=0
virtual void setApiService(const std::shared_ptr< api::ApiService > &api_service)=0
virtual outcome::result< primitives::BlockHeader > getHeader()=0
primitives::BlockNumber BlockNumber
Definition: chain_api.hpp:26
uint32_t BlockNumber
Definition: common.hpp:18
virtual outcome::result< uint32_t > subscribeFinalizedHeads()=0
virtual outcome::result< uint32_t > subscribeNewHeads()=0
virtual outcome::result< void > unsubscribeNewHeads(uint32_t subscription_id)=0
common::Hash256 BlockHash
Definition: block_id.hpp:15
virtual outcome::result< BlockHash > getBlockHash() const =0
virtual outcome::result< void > unsubscribeFinalizedHeads(uint32_t subscription_id)=0
virtual outcome::result< primitives::BlockHash > getFinalizedHead() const =0
boost::variant< BlockNumber, std::string > ValueType
Definition: chain_api.hpp:28