hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_ordering_service_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_ORDERING_SERVICE_IMPL_HPP
7 #define IROHA_ON_DEMAND_ORDERING_SERVICE_IMPL_HPP
8 
10 
11 #include <queue>
12 #include <shared_mutex>
13 #include <unordered_map>
14 
15 #include <tbb/concurrent_queue.h>
17 #include "logger/logger.hpp"
19 
20 namespace iroha {
21  namespace ametsuchi {
22  class TxPresenceCache;
23  }
24  namespace ordering {
26  public:
40  size_t transaction_limit,
41  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
42  proposal_factory,
43  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
44  size_t number_of_proposals = 3,
45  const consensus::Round &initial_round = {2, kFirstRejectRound},
46  logger::Logger log = logger::log("OnDemandOrderingServiceImpl"));
47 
48  // --------------------- | OnDemandOrderingService |_---------------------
49 
50  void onCollaborationOutcome(consensus::Round round) override;
51 
52  // ----------------------- | OdOsNotification | --------------------------
53 
54  void onBatches(consensus::Round, CollectionType batches) override;
55 
56  boost::optional<ProposalType> onRequestProposal(
57  consensus::Round round) override;
58 
59  private:
64  void packNextProposals(const consensus::Round &round);
65 
71  void tryErase();
72 
77  ProposalType emitProposal(const consensus::Round &round);
78 
82  bool batchAlreadyProcessed(
84 
88  size_t transaction_limit_;
89 
93  size_t number_of_proposals_;
94 
98  std::queue<consensus::Round> round_queue_;
99 
103  std::unordered_map<consensus::Round,
104  ProposalType,
106  proposal_map_;
107 
111  std::unordered_map<consensus::Round,
112  tbb::concurrent_queue<TransactionBatchType>,
114  current_proposals_;
115 
119  std::shared_timed_mutex lock_;
120 
121  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
122  proposal_factory_;
123 
127  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache_;
128 
132  logger::Logger log_;
133  };
134  } // namespace ordering
135 } // namespace iroha
136 
137 #endif // IROHA_ON_DEMAND_ORDERING_SERVICE_IMPL_HPP
Definition: on_demand_ordering_service.hpp:17
Definition: on_demand_ordering_service_impl.hpp:25
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
const consensus::RejectRoundType kFirstRejectRound
Definition: on_demand_common.cpp:11
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: transaction_batch.hpp:22
Definition: round.hpp:51
Definition: round.hpp:31
std::vector< TransactionBatchType > CollectionType
Definition: on_demand_os_transport.hpp:47