hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_ordering_gate.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_ORDERING_GATE_HPP
7 #define IROHA_ON_DEMAND_ORDERING_GATE_HPP
8 
10 
11 #include <shared_mutex>
12 
13 #include <boost/variant.hpp>
14 #include <rxcpp/rx.hpp>
18 #include "logger/logger_fwd.hpp"
22 
23 namespace iroha {
24  namespace ametsuchi {
25  class TxPresenceCache;
26  }
27 
28  namespace ordering {
29 
35  public:
36  struct RoundSwitch {
38  std::shared_ptr<const LedgerState> ledger_state;
39 
41  std::shared_ptr<const LedgerState> ledger_state)
42  : next_round(std::move(next_round)),
43  ledger_state(std::move(ledger_state)) {}
44  };
45 
47  std::shared_ptr<OnDemandOrderingService> ordering_service,
48  std::shared_ptr<transport::OdOsNotification> network_client,
49  rxcpp::observable<
50  std::shared_ptr<const cache::OrderingGateCache::HashesSetType>>
51  processed_tx_hashes,
52  rxcpp::observable<RoundSwitch> round_switch_events,
53  std::shared_ptr<cache::OrderingGateCache>
54  cache, // TODO: IR-1863 12.11.18 kamilsa change cache to
55  // unique_ptr
56  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
57  factory,
58  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
59  std::shared_ptr<ProposalCreationStrategy> proposal_creation_strategy,
60  size_t transaction_limit,
61  logger::LoggerPtr log);
62 
63  ~OnDemandOrderingGate() override;
64 
65  void propagateBatch(
66  std::shared_ptr<shared_model::interface::TransactionBatch> batch)
67  override;
68 
69  rxcpp::observable<network::OrderingEvent> onProposal() override;
70 
71  private:
75  boost::optional<std::shared_ptr<const shared_model::interface::Proposal>>
76  processProposalRequest(
77  boost::optional<
78  std::shared_ptr<const OnDemandOrderingService::ProposalType>>
79  proposal) const;
80 
81  void sendCachedTransactions();
82 
86  std::shared_ptr<const shared_model::interface::Proposal>
87  removeReplaysAndDuplicates(
88  std::shared_ptr<const shared_model::interface::Proposal> proposal)
89  const;
90 
91  logger::LoggerPtr log_;
92 
94  size_t transaction_limit_;
95  std::shared_ptr<OnDemandOrderingService> ordering_service_;
96  std::shared_ptr<transport::OdOsNotification> network_client_;
97  rxcpp::composite_subscription processed_tx_hashes_subscription_;
98  rxcpp::composite_subscription round_switch_subscription_;
99  std::shared_ptr<cache::OrderingGateCache> cache_;
100  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
101  proposal_factory_;
102  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache_;
103 
104  rxcpp::composite_subscription proposal_notifier_lifetime_;
105  rxcpp::subjects::subject<network::OrderingEvent> proposal_notifier_;
106  };
107 
108  } // namespace ordering
109 } // namespace iroha
110 
111 #endif // IROHA_ON_DEMAND_ORDERING_GATE_HPP
Definition: ordering_gate.hpp:28
RoundSwitch(consensus::Round next_round, std::shared_ptr< const LedgerState > ledger_state)
Definition: on_demand_ordering_gate.hpp:40
Definition: peer.hpp:48
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:14
Definition: on_demand_ordering_gate.hpp:36
std::shared_ptr< const LedgerState > ledger_state
Definition: on_demand_ordering_gate.hpp:38
Definition: round.hpp:31
Definition: on_demand_ordering_gate.hpp:34
consensus::Round next_round
Definition: on_demand_ordering_gate.hpp:37