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>
13 #include <rxcpp/rx-lite.hpp>
17 #include "logger/logger_fwd.hpp"
20 
21 namespace iroha {
22  namespace ametsuchi {
23  class CommandExecutor;
24  }
25 
26  namespace simulator {
27 
29  public:
32 
33  Simulator(
34  // TODO IR-598 mboldyrev 2019.08.10: remove command_executor from
35  // Simulator
36  std::unique_ptr<iroha::ametsuchi::CommandExecutor> command_executor,
37  std::shared_ptr<network::OrderingGate> ordering_gate,
38  std::shared_ptr<validation::StatefulValidator> statefulValidator,
39  std::shared_ptr<ametsuchi::TemporaryFactory> factory,
40  std::shared_ptr<CryptoSignerType> crypto_signer,
41  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
43  logger::LoggerPtr log);
44 
45  ~Simulator() override;
46 
47  std::shared_ptr<validation::VerifiedProposalAndErrors> processProposal(
48  const shared_model::interface::Proposal &proposal) override;
49 
50  rxcpp::observable<VerifiedProposalCreatorEvent> onVerifiedProposal()
51  override;
52 
53  boost::optional<std::shared_ptr<shared_model::interface::Block>>
54  processVerifiedProposal(
55  const std::shared_ptr<iroha::validation::VerifiedProposalAndErrors>
56  &verified_proposal_and_errors,
57  const TopBlockInfo &top_block_info) override;
58 
59  rxcpp::observable<BlockCreatorEvent> onBlock() override;
60 
61  private:
62  // internal
63  std::shared_ptr<iroha::ametsuchi::CommandExecutor> command_executor_;
64 
65  rxcpp::composite_subscription notifier_lifetime_;
66  rxcpp::subjects::subject<VerifiedProposalCreatorEvent> notifier_;
67  rxcpp::composite_subscription block_notifier_lifetime_;
68  rxcpp::subjects::subject<BlockCreatorEvent> block_notifier_;
69 
70  rxcpp::composite_subscription proposal_subscription_;
71  rxcpp::composite_subscription verified_proposal_subscription_;
72 
73  std::shared_ptr<validation::StatefulValidator> validator_;
74  std::shared_ptr<ametsuchi::TemporaryFactory> ametsuchi_factory_;
75  std::shared_ptr<CryptoSignerType> crypto_signer_;
76  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
77  block_factory_;
78 
79  logger::LoggerPtr log_;
80  };
81  } // namespace simulator
82 } // namespace iroha
83 
84 #endif // IROHA_SIMULATOR_HPP
static const model::converters::PbBlockFactory block_factory
Definition: sha3_hash.cpp:15
Definition: simulator.hpp:28
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