Kagome
Polkadot Runtime Engine in C++17
author_api_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_API_SERVICE_AUTHOR_IMPL_AUTHOR_API_IMPL_HPP
7 #define KAGOME_CORE_API_SERVICE_AUTHOR_IMPL_AUTHOR_API_IMPL_HPP
8 
15 
16 #include <unordered_set>
17 
18 #include <libp2p/peer/peer_id.hpp>
19 
20 #include "common/blob.hpp"
21 #include "log/logger.hpp"
24 
25 namespace kagome::api {
26  class ApiService;
27 }
28 namespace kagome::blockchain {
29  class BlockTree;
30 }
31 namespace kagome::crypto {
32  class CryptoStore;
33  class Hasher;
34  class KeyFileStorage;
35  class SessionKeys;
36 } // namespace kagome::crypto
37 namespace kagome::network {
39 }
40 namespace kagome::primitives {
41  struct Extrinsic;
42 }
43 namespace kagome::runtime {
44  class SessionKeysApi;
45 }
47  class TransactionPool;
48 }
50  template <typename Event, typename Receiver, typename... Arguments>
51  class Subscriber;
52 }
53 
54 namespace kagome::api {
55 
56  class AuthorApiImpl : public AuthorApi {
57  template <class T>
58  using sptr = std::shared_ptr<T>;
59  template <class T>
60  using uptr = std::unique_ptr<T>;
61 
62  public:
75  sptr<blockchain::BlockTree> block_tree);
76 
77  ~AuthorApiImpl() override = default;
78 
79  void setApiService(sptr<api::ApiService> const &api_service) override;
80 
81  outcome::result<common::Hash256> submitExtrinsic(
82  TransactionSource source,
83  const primitives::Extrinsic &extrinsic) override;
84 
85  outcome::result<void> insertKey(
86  crypto::KeyTypeId key_type,
87  const gsl::span<const uint8_t> &seed,
88  const gsl::span<const uint8_t> &public_key) override;
89 
90  outcome::result<common::Buffer> rotateKeys() override;
91 
92  outcome::result<bool> hasSessionKeys(
93  const gsl::span<const uint8_t> &keys) override;
94 
95  outcome::result<bool> hasKey(const gsl::span<const uint8_t> &public_key,
96  crypto::KeyTypeId key_type) override;
97 
98  outcome::result<std::vector<primitives::Extrinsic>> pendingExtrinsics()
99  override;
100 
101  outcome::result<std::vector<primitives::Extrinsic>> removeExtrinsic(
102  const std::vector<primitives::ExtrinsicKey> &keys) override;
103 
104  outcome::result<SubscriptionId> submitAndWatchExtrinsic(
105  Extrinsic extrinsic) override;
106 
107  outcome::result<bool> unwatchExtrinsic(
108  SubscriptionId subscription_id) override;
109 
110  private:
116  std::weak_ptr<api::ApiService> api_service_;
118 
120  };
121 } // namespace kagome::api
122 
123 #endif // KAGOME_CORE_API_SERVICE_AUTHOR_IMPL_AUTHOR_API_IMPL_HPP
std::weak_ptr< api::ApiService > api_service_
sptr< runtime::SessionKeysApi > keys_api_
uint32_t KeyTypeId
Key type identifier.
Definition: key_type.hpp:21
std::unique_ptr< T > uptr
sptr< crypto::KeyFileStorage > key_store_
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
sptr< transaction_pool::TransactionPool > pool_
sptr< blockchain::BlockTree > block_tree_
primitives::SubscriptionId SubscriptionId
Definition: author_api.hpp:30
Extrinsic class represents extrinsic.
Definition: extrinsic.hpp:24
std::shared_ptr< T > sptr
sptr< crypto::CryptoStore > store_
sptr< crypto::SessionKeys > keys_