hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
simulator.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SIMULATOR_HPP
7 #define IROHA_SIMULATOR_HPP
8 
11 
12 #include <boost/optional.hpp>
16 #include "logger/logger_fwd.hpp"
19 
20 namespace iroha {
21  namespace ametsuchi {
22  class CommandExecutor;
23  }
24 
25  namespace simulator {
26 
28  public:
31 
32  Simulator(
33  // TODO IR-598 mboldyrev 2019.08.10: remove command_executor from
34  // Simulator
35  std::unique_ptr<iroha::ametsuchi::CommandExecutor> command_executor,
36  std::shared_ptr<network::OrderingGate> ordering_gate,
37  std::shared_ptr<validation::StatefulValidator> statefulValidator,
38  std::shared_ptr<ametsuchi::TemporaryFactory> factory,
39  std::shared_ptr<CryptoSignerType> crypto_signer,
40  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
42  logger::LoggerPtr log);
43 
44  ~Simulator() override;
45 
46  std::shared_ptr<validation::VerifiedProposalAndErrors> processProposal(
47  const shared_model::interface::Proposal &proposal) override;
48 
49  rxcpp::observable<VerifiedProposalCreatorEvent> onVerifiedProposal()
50  override;
51 
52  boost::optional<std::shared_ptr<shared_model::interface::Block>>
53  processVerifiedProposal(
54  const std::shared_ptr<iroha::validation::VerifiedProposalAndErrors>
55  &verified_proposal_and_errors,
56  const TopBlockInfo &top_block_info) override;
57 
58  rxcpp::observable<BlockCreatorEvent> onBlock() override;
59 
60  private:
61  // internal
62  std::shared_ptr<iroha::ametsuchi::CommandExecutor> command_executor_;
63 
64  rxcpp::composite_subscription notifier_lifetime_;
65  rxcpp::subjects::subject<VerifiedProposalCreatorEvent> notifier_;
66  rxcpp::composite_subscription block_notifier_lifetime_;
67  rxcpp::subjects::subject<BlockCreatorEvent> block_notifier_;
68 
69  rxcpp::composite_subscription proposal_subscription_;
70  rxcpp::composite_subscription verified_proposal_subscription_;
71 
72  std::shared_ptr<validation::StatefulValidator> validator_;
73  std::shared_ptr<ametsuchi::TemporaryFactory> ametsuchi_factory_;
74  std::shared_ptr<CryptoSignerType> crypto_signer_;
75  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
76  block_factory_;
77 
78  logger::LoggerPtr log_;
79  };
80  } // namespace simulator
81 } // namespace iroha
82 
83 #endif // IROHA_SIMULATOR_HPP
static const model::converters::PbBlockFactory block_factory
Definition: sha3_hash.cpp:15
Definition: simulator.hpp:27
Definition: proposal.hpp:17
Definition: ledger_state.hpp:14
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block.hpp:16
Definition: verified_proposal_creator.hpp:28
Definition: block_query.hpp:14
Definition: block_creator.hpp:22
Definition: abstract_crypto_model_signer.hpp:16