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 simulator {
22 
24  public:
27 
28  Simulator(
29  std::shared_ptr<network::OrderingGate> ordering_gate,
30  std::shared_ptr<validation::StatefulValidator> statefulValidator,
31  std::shared_ptr<ametsuchi::TemporaryFactory> factory,
32  std::shared_ptr<CryptoSignerType> crypto_signer,
33  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
35  logger::LoggerPtr log);
36 
37  ~Simulator() override;
38 
39  boost::optional<std::shared_ptr<validation::VerifiedProposalAndErrors>>
41  const shared_model::interface::Proposal &proposal) override;
42 
43  rxcpp::observable<VerifiedProposalCreatorEvent> onVerifiedProposal()
44  override;
45 
46  boost::optional<std::shared_ptr<shared_model::interface::Block>>
48  const std::shared_ptr<iroha::validation::VerifiedProposalAndErrors>
49  &verified_proposal_and_errors,
50  const TopBlockInfo &top_block_info) override;
51 
52  rxcpp::observable<BlockCreatorEvent> onBlock() override;
53 
54  private:
55  // internal
56  rxcpp::composite_subscription notifier_lifetime_;
57  rxcpp::subjects::subject<VerifiedProposalCreatorEvent> notifier_;
58  rxcpp::composite_subscription block_notifier_lifetime_;
59  rxcpp::subjects::subject<BlockCreatorEvent> block_notifier_;
60 
61  rxcpp::composite_subscription proposal_subscription_;
62  rxcpp::composite_subscription verified_proposal_subscription_;
63 
64  std::shared_ptr<validation::StatefulValidator> validator_;
65  std::shared_ptr<ametsuchi::TemporaryFactory> ametsuchi_factory_;
66  std::shared_ptr<CryptoSignerType> crypto_signer_;
67  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
68  block_factory_;
69 
70  logger::LoggerPtr log_;
71  };
72  } // namespace simulator
73 } // namespace iroha
74 
75 #endif // IROHA_SIMULATOR_HPP
static const model::converters::PbBlockFactory block_factory
Definition: sha3_hash.cpp:15
Definition: simulator.hpp:23
~Simulator() override
Definition: simulator.cpp:70
Simulator(std::shared_ptr< network::OrderingGate > ordering_gate, std::shared_ptr< validation::StatefulValidator > statefulValidator, std::shared_ptr< ametsuchi::TemporaryFactory > factory, std::shared_ptr< CryptoSignerType > crypto_signer, std::unique_ptr< shared_model::interface::UnsafeBlockFactory > block_factory, logger::LoggerPtr log)
Definition: simulator.cpp:17
rxcpp::observable< VerifiedProposalCreatorEvent > onVerifiedProposal() override
Definition: simulator.cpp:78
Definition: proposal.hpp:17
Definition: ledger_state.hpp:14
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block.hpp:15
boost::optional< std::shared_ptr< shared_model::interface::Block > > processVerifiedProposal(const std::shared_ptr< iroha::validation::VerifiedProposalAndErrors > &verified_proposal_and_errors, const TopBlockInfo &top_block_info) override
Definition: simulator.cpp:108
Definition: verified_proposal_creator.hpp:28
Definition: block_query.hpp:14
rxcpp::observable< BlockCreatorEvent > onBlock() override
Definition: simulator.cpp:131
boost::optional< std::shared_ptr< validation::VerifiedProposalAndErrors > > processProposal(const shared_model::interface::Proposal &proposal) override
Definition: simulator.cpp:83
Definition: block_creator.hpp:22
Definition: abstract_crypto_model_signer.hpp:16