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.hpp"
21 
22 namespace iroha {
23  namespace ametsuchi {
24  class TxPresenceCache;
25  }
26 
27  namespace ordering {
28 
34  public:
38  struct BlockEvent {
43  };
44 
48  struct EmptyEvent {
51  };
52 
53  using BlockRoundEventType = boost::variant<BlockEvent, EmptyEvent>;
54 
56  std::shared_ptr<OnDemandOrderingService> ordering_service,
57  std::shared_ptr<transport::OdOsNotification> network_client,
58  rxcpp::observable<BlockRoundEventType> events,
59  std::shared_ptr<cache::OrderingGateCache>
60  cache, // TODO: IR-1863 12.11.18 kamilsa change cache to
61  // unique_ptr
62  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
63  factory,
64  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
65  consensus::Round initial_round,
66  logger::Logger log = logger::log("OnDemandOrderingGate"));
67 
68  ~OnDemandOrderingGate() override;
69 
70  void propagateBatch(
71  std::shared_ptr<shared_model::interface::TransactionBatch> batch)
72  override;
73 
74  rxcpp::observable<network::OrderingEvent> onProposal() override;
75 
76  [[deprecated("Use ctor")]] void setPcs(
77  const iroha::network::PeerCommunicationService &pcs) override;
78 
79  private:
83  boost::optional<std::shared_ptr<shared_model::interface::Proposal>>
84  processProposalRequest(
85  boost::optional<OnDemandOrderingService::ProposalType> &&proposal)
86  const;
87 
91  boost::optional<std::shared_ptr<shared_model::interface::Proposal>>
92  removeReplays(shared_model::interface::Proposal &&proposal) const;
93 
94  logger::Logger log_;
95  std::shared_ptr<OnDemandOrderingService> ordering_service_;
96  std::shared_ptr<transport::OdOsNotification> network_client_;
97  rxcpp::composite_subscription events_subscription_;
98  std::shared_ptr<cache::OrderingGateCache> cache_;
99  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
100  proposal_factory_;
101  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache_;
102 
103  consensus::Round current_round_;
104  rxcpp::subjects::subject<network::OrderingEvent> proposal_notifier_;
105  mutable std::shared_timed_mutex mutex_;
106  };
107 
108  } // namespace ordering
109 } // namespace iroha
110 
111 #endif // IROHA_ON_DEMAND_ORDERING_GATE_HPP
Definition: ordering_gate.hpp:28
boost::variant< BlockEvent, EmptyEvent > BlockRoundEventType
Definition: on_demand_ordering_gate.hpp:53
Definition: peer_communication_service.hpp:27
Definition: proposal.hpp:17
consensus::Round round
next round number
Definition: on_demand_ordering_gate.hpp:50
Definition: on_demand_ordering_gate.hpp:48
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
std::unordered_set< shared_model::crypto::Hash, shared_model::crypto::Hash::Hasher > HashesSetType
Definition: ordering_gate_cache.hpp:49
cache::OrderingGateCache::HashesSetType hashes
hashes of processed transactions
Definition: on_demand_ordering_gate.hpp:42
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: round.hpp:31
Definition: on_demand_ordering_gate.hpp:33
consensus::Round round
next round number
Definition: on_demand_ordering_gate.hpp:40
Definition: on_demand_ordering_gate.hpp:38