Kagome
Polkadot Runtime Engine in C++17
block_executor_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CONSENSUS_BLOCKEXECUTORIMPL
7 #define KAGOME_CONSENSUS_BLOCKEXECUTORIMPL
8 
10 
11 #include <libp2p/peer/peer_id.hpp>
12 
14 #include "clock/timer.hpp"
18 #include "crypto/hasher.hpp"
19 #include "log/logger.hpp"
20 #include "metrics/metrics.hpp"
24 #include "telemetry/service.hpp"
26 
27 namespace kagome::runtime {
28  class OffchainWorkerApi;
29 };
30 
31 namespace kagome::consensus::babe {
32  class BabeConfigRepository;
33  class ConsistencyKeeper;
34 } // namespace kagome::consensus::babe
35 
36 namespace kagome::blockchain {
37  class DigestTracker;
38 }
39 
40 namespace kagome::consensus {
41 
43  : public BlockExecutor,
44  public std::enable_shared_from_this<BlockExecutorImpl> {
45  public:
46  enum class Error { INVALID_BLOCK = 1, PARENT_NOT_FOUND, INTERNAL_ERROR };
47 
49  std::shared_ptr<blockchain::BlockTree> block_tree,
50  std::shared_ptr<runtime::Core> core,
51  std::shared_ptr<consensus::babe::BabeConfigRepository> babe_config_repo,
52  std::shared_ptr<BlockValidator> block_validator,
53  std::shared_ptr<grandpa::Environment> grandpa_environment,
54  std::shared_ptr<transaction_pool::TransactionPool> tx_pool,
55  std::shared_ptr<crypto::Hasher> hasher,
56  std::shared_ptr<blockchain::DigestTracker> digest_tracker,
57  std::shared_ptr<BabeUtil> babe_util,
58  std::shared_ptr<runtime::OffchainWorkerApi> offchain_worker_api,
59  std::shared_ptr<babe::ConsistencyKeeper> consistency_keeper);
60 
61  outcome::result<void> applyBlock(primitives::BlockData &&block) override;
62 
63  outcome::result<void> applyJustification(
64  const primitives::BlockInfo &block_info,
65  const primitives::Justification &justification) override;
66 
67  private:
68  std::shared_ptr<blockchain::BlockTree> block_tree_;
69  std::shared_ptr<runtime::Core> core_;
70  std::shared_ptr<consensus::babe::BabeConfigRepository> babe_config_repo_;
71  std::shared_ptr<BlockValidator> block_validator_;
72  std::shared_ptr<grandpa::Environment> grandpa_environment_;
73  std::shared_ptr<transaction_pool::TransactionPool> tx_pool_;
74  std::shared_ptr<crypto::Hasher> hasher_;
75  std::shared_ptr<blockchain::DigestTracker> digest_tracker_;
76  std::shared_ptr<BabeUtil> babe_util_;
77  std::shared_ptr<runtime::OffchainWorkerApi> offchain_worker_api_;
78  std::shared_ptr<babe::ConsistencyKeeper> consistency_keeper_;
79 
80  // Justification Store for Future Applying
81  std::map<primitives::BlockInfo, primitives::Justification> justifications_;
82 
83  // Metrics
86 
89  };
90 
91 } // namespace kagome::consensus
92 
94 
95 #endif // KAGOME_CONSENSUS_BLOCKEXECUTORIMPL
std::shared_ptr< transaction_pool::TransactionPool > tx_pool_
std::map< primitives::BlockInfo, primitives::Justification > justifications_
std::shared_ptr< runtime::OffchainWorkerApi > offchain_worker_api_
A histogram metric to represent aggregatable distributions of events.
Definition: metrics.hpp:108
std::unique_ptr< Registry > RegistryPtr
Definition: metrics.hpp:15
RegistryPtr createRegistry()
std::shared_ptr< consensus::babe::BabeConfigRepository > babe_config_repo_
OUTCOME_HPP_DECLARE_ERROR(kagome::consensus, BlockExecutorImpl::Error)
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
std::shared_ptr< grandpa::Environment > grandpa_environment_
std::shared_ptr< runtime::Core > core_
std::shared_ptr< crypto::Hasher > hasher_
std::shared_ptr< blockchain::DigestTracker > digest_tracker_
std::shared_ptr< BabeUtil > babe_util_
std::shared_ptr< blockchain::BlockTree > block_tree_
std::shared_ptr< babe::ConsistencyKeeper > consistency_keeper_
std::shared_ptr< TelemetryService > Telemetry
Definition: service.hpp:86
std::shared_ptr< BlockValidator > block_validator_