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