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"
21 
22 namespace iroha {
23  namespace ametsuchi {
24  class TxPresenceCache;
25  }
26 
27  namespace ordering {
28 
34  public:
35  struct RoundSwitch {
37  std::shared_ptr<LedgerState> ledger_state;
38 
40  std::shared_ptr<LedgerState> ledger_state)
41  : next_round(std::move(next_round)),
42  ledger_state(std::move(ledger_state)) {}
43  };
44 
46  std::shared_ptr<OnDemandOrderingService> ordering_service,
47  std::shared_ptr<transport::OdOsNotification> network_client,
48  rxcpp::observable<
49  std::shared_ptr<const cache::OrderingGateCache::HashesSetType>>
50  processed_tx_hashes,
51  rxcpp::observable<RoundSwitch> round_switch_events,
52  std::shared_ptr<cache::OrderingGateCache>
53  cache, // TODO: IR-1863 12.11.18 kamilsa change cache to
54  // unique_ptr
55  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
56  factory,
57  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
58  size_t transaction_limit,
59  logger::LoggerPtr log);
60 
61  ~OnDemandOrderingGate() override;
62 
63  void propagateBatch(
64  std::shared_ptr<shared_model::interface::TransactionBatch> batch)
65  override;
66 
67  rxcpp::observable<network::OrderingEvent> onProposal() override;
68 
69  private:
73  boost::optional<std::shared_ptr<const shared_model::interface::Proposal>>
74  processProposalRequest(
75  boost::optional<
76  std::shared_ptr<const OnDemandOrderingService::ProposalType>>
77  proposal) const;
78 
79  void sendCachedTransactions();
80 
84  std::shared_ptr<const shared_model::interface::Proposal> removeReplays(
85  std::shared_ptr<const shared_model::interface::Proposal> proposal)
86  const;
87 
88  logger::LoggerPtr log_;
89 
91  size_t transaction_limit_;
92  std::shared_ptr<OnDemandOrderingService> ordering_service_;
93  std::shared_ptr<transport::OdOsNotification> network_client_;
94  rxcpp::composite_subscription processed_tx_hashes_subscription_;
95  rxcpp::composite_subscription round_switch_subscription_;
96  std::shared_ptr<cache::OrderingGateCache> cache_;
97  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
98  proposal_factory_;
99  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache_;
100 
101  rxcpp::composite_subscription proposal_notifier_lifetime_;
102  rxcpp::subjects::subject<network::OrderingEvent> proposal_notifier_;
103  };
104 
105  } // namespace ordering
106 } // namespace iroha
107 
108 #endif // IROHA_ON_DEMAND_ORDERING_GATE_HPP
Definition: ordering_gate.hpp:28
Definition: peer.hpp:48
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
std::shared_ptr< LedgerState > ledger_state
Definition: on_demand_ordering_gate.hpp:37
Definition: block_query.hpp:14
RoundSwitch(consensus::Round next_round, std::shared_ptr< LedgerState > ledger_state)
Definition: on_demand_ordering_gate.hpp:39
Definition: on_demand_ordering_gate.hpp:35
Definition: round.hpp:31
Definition: on_demand_ordering_gate.hpp:33
consensus::Round next_round
Definition: on_demand_ordering_gate.hpp:36