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.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::Logger log = logger::log("Simulator"));
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::subjects::subject<VerifiedProposalCreatorEvent> notifier_;
58  rxcpp::subjects::subject<BlockCreatorEvent> block_notifier_;
59 
60  rxcpp::composite_subscription proposal_subscription_;
61  rxcpp::composite_subscription verified_proposal_subscription_;
62 
63  std::shared_ptr<validation::StatefulValidator> validator_;
64  std::shared_ptr<ametsuchi::TemporaryFactory> ametsuchi_factory_;
65  std::shared_ptr<ametsuchi::BlockQueryFactory> block_query_factory_;
66  std::shared_ptr<CryptoSignerType> crypto_signer_;
67  std::unique_ptr<shared_model::interface::UnsafeBlockFactory>
68  block_factory_;
69 
70  logger::Logger log_;
71 
72  // last block
73  std::shared_ptr<shared_model::interface::Block> last_block;
74  };
75  } // namespace simulator
76 } // namespace iroha
77 
78 #endif // IROHA_SIMULATOR_HPP
static const model::converters::PbBlockFactory block_factory
Definition: sha3_hash.cpp:14
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:124
Definition: simulator.hpp:24
~Simulator() override
Definition: simulator.cpp:65
rxcpp::observable< VerifiedProposalCreatorEvent > onVerifiedProposal() override
Definition: simulator.cpp:71
Definition: proposal.hpp:17
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::Logger log=logger::log("Simulator"))
Definition: simulator.cpp:16
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block.hpp:15
Definition: verified_proposal_creator.hpp:28
Definition: block_query.hpp:16
Logger log(const std::string &tag)
Definition: logger.cpp:48
rxcpp::observable< BlockCreatorEvent > onBlock() override
Definition: simulator.cpp:154
boost::optional< std::shared_ptr< validation::VerifiedProposalAndErrors > > processProposal(const shared_model::interface::Proposal &proposal) override
Definition: simulator.cpp:76
Definition: block_creator.hpp:22
Definition: abstract_crypto_model_signer.hpp:16