Kagome
Polkadot Runtime Engine in C++17
signer.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_PARACHAIN_AVAILABILITY_BITFIELD_SIGNER_HPP
7 #define KAGOME_PARACHAIN_AVAILABILITY_BITFIELD_SIGNER_HPP
8 
9 #include <libp2p/basic/scheduler.hpp>
10 
11 #include "crypto/hasher.hpp"
17 
18 namespace kagome::parachain {
20  class BitfieldSigner : public std::enable_shared_from_this<BitfieldSigner> {
21  public:
22  BitfieldSigner(std::shared_ptr<crypto::Hasher> hasher,
23  std::shared_ptr<ValidatorSignerFactory> signer_factory,
24  std::shared_ptr<libp2p::basic::Scheduler> scheduler,
25  std::shared_ptr<runtime::ParachainHost> parachain_api,
26  std::shared_ptr<AvailabilityStore> store,
27  std::shared_ptr<BitfieldStore> bitfield_store);
28 
30  void start(std::shared_ptr<primitives::events::ChainSubscriptionEngine>
31  chain_sub_engine);
32 
34  outcome::result<void> sign(const ValidatorSigner &signer);
35 
36  private:
38 
39  outcome::result<void> onBlock(const BlockHash &relay_parent);
40 
41  std::shared_ptr<crypto::Hasher> hasher_;
42  std::shared_ptr<ValidatorSignerFactory> signer_factory_;
43  std::shared_ptr<libp2p::basic::Scheduler> scheduler_;
44  std::shared_ptr<runtime::ParachainHost> parachain_api_;
45  std::shared_ptr<AvailabilityStore> store_;
46  std::shared_ptr<BitfieldStore> bitfield_store_;
47  std::shared_ptr<primitives::events::ChainEventSubscriber> chain_sub_;
48  };
49 } // namespace kagome::parachain
50 
51 #endif // KAGOME_PARACHAIN_AVAILABILITY_BITFIELD_SIGNER_HPP
std::shared_ptr< runtime::ParachainHost > parachain_api_
Definition: signer.hpp:44
std::shared_ptr< BitfieldStore > bitfield_store_
Definition: signer.hpp:46
std::shared_ptr< crypto::Hasher > hasher_
Definition: signer.hpp:41
outcome::result< void > sign(const ValidatorSigner &signer)
Sign bitfield for given block.
Definition: signer.cpp:59
std::shared_ptr< libp2p::basic::Scheduler > scheduler_
Definition: signer.hpp:43
outcome::result< void > onBlock(const BlockHash &relay_parent)
Definition: signer.cpp:77
std::shared_ptr< primitives::events::ChainEventSubscriber > chain_sub_
Definition: signer.hpp:47
std::shared_ptr< AvailabilityStore > store_
Definition: signer.hpp:45
BitfieldSigner(std::shared_ptr< crypto::Hasher > hasher, std::shared_ptr< ValidatorSignerFactory > signer_factory, std::shared_ptr< libp2p::basic::Scheduler > scheduler, std::shared_ptr< runtime::ParachainHost > parachain_api, std::shared_ptr< AvailabilityStore > store, std::shared_ptr< BitfieldStore > bitfield_store)
Definition: signer.cpp:20
common::Hash256 BlockHash
Definition: block_id.hpp:15
Signs payload with signing context and validator keypair.
Definition: signer.hpp:52
Signs, stores and broadcasts bitfield for every new head.
Definition: signer.hpp:20
std::shared_ptr< ValidatorSignerFactory > signer_factory_
Definition: signer.hpp:42
void start(std::shared_ptr< primitives::events::ChainSubscriptionEngine > chain_sub_engine)
Subscribes to new heads.
Definition: signer.cpp:34