Kagome
Polkadot Runtime Engine in C++17
api_service.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_API_SERVICE_HPP
7 #define KAGOME_CORE_API_SERVICE_HPP
8 
9 #include <vector>
10 
11 #include "common/buffer.hpp"
12 #include "outcome/outcome.hpp"
14 
15 namespace kagome::api {
16 
20  class ApiService {
21  public:
23  using PubsubSubscriptionId = uint32_t;
24 
25  template <class T>
26  using sptr = std::shared_ptr<T>;
27 
28  virtual ~ApiService() = default;
29 
31  virtual bool prepare() = 0;
32 
34  virtual bool start() = 0;
35 
37  virtual void stop() = 0;
38 
39  virtual outcome::result<uint32_t> subscribeSessionToKeys(
40  const std::vector<common::Buffer> &keys) = 0;
41 
42  virtual outcome::result<bool> unsubscribeSessionFromIds(
43  const std::vector<PubsubSubscriptionId> &subscription_id) = 0;
44 
45  virtual outcome::result<PubsubSubscriptionId> subscribeFinalizedHeads() = 0;
46  virtual outcome::result<bool> unsubscribeFinalizedHeads(
47  PubsubSubscriptionId subscription_id) = 0;
48 
49  virtual outcome::result<PubsubSubscriptionId> subscribeNewHeads() = 0;
50  virtual outcome::result<bool> unsubscribeNewHeads(
51  PubsubSubscriptionId subscription_id) = 0;
52 
53  virtual outcome::result<PubsubSubscriptionId> subscribeRuntimeVersion() = 0;
54  virtual outcome::result<bool> unsubscribeRuntimeVersion(
55  PubsubSubscriptionId subscription_id) = 0;
56 
57  virtual outcome::result<PubsubSubscriptionId>
59  const primitives::Transaction::Hash &tx_hash) = 0;
60 
61  virtual outcome::result<bool> unsubscribeFromExtrinsicLifecycle(
62  PubsubSubscriptionId subscription_id) = 0;
63  };
64 } // namespace kagome::api
65 
66 #endif // KAGOME_CORE_API_SERVICE_HPP
virtual ~ApiService()=default
virtual outcome::result< PubsubSubscriptionId > subscribeNewHeads()=0
virtual outcome::result< PubsubSubscriptionId > subscribeRuntimeVersion()=0
virtual outcome::result< bool > unsubscribeFinalizedHeads(PubsubSubscriptionId subscription_id)=0
virtual outcome::result< bool > unsubscribeSessionFromIds(const std::vector< PubsubSubscriptionId > &subscription_id)=0
std::shared_ptr< T > sptr
Definition: api_service.hpp:26
uint32_t PubsubSubscriptionId
subscription id for pubsub API methods
Definition: api_service.hpp:23
virtual outcome::result< bool > unsubscribeNewHeads(PubsubSubscriptionId subscription_id)=0
virtual bool start()=0
virtual outcome::result< bool > unsubscribeFromExtrinsicLifecycle(PubsubSubscriptionId subscription_id)=0
virtual outcome::result< bool > unsubscribeRuntimeVersion(PubsubSubscriptionId subscription_id)=0
virtual outcome::result< PubsubSubscriptionId > subscribeFinalizedHeads()=0
virtual void stop()=0
virtual outcome::result< PubsubSubscriptionId > subscribeForExtrinsicLifecycle(const primitives::Transaction::Hash &tx_hash)=0
virtual bool prepare()=0
virtual outcome::result< uint32_t > subscribeSessionToKeys(const std::vector< common::Buffer > &keys)=0