hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_connection_manager.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_CONNECTION_MANAGER_HPP
7 #define IROHA_ON_DEMAND_CONNECTION_MANAGER_HPP
8 
10 
11 #include <shared_mutex>
12 
13 #include <rxcpp/rx.hpp>
14 #include "logger/logger.hpp"
15 
16 namespace iroha {
17  namespace ordering {
18 
23  public:
31  enum PeerType {
37  };
38 
40  template <typename T>
41  using PeerCollectionType = std::array<T, kCount>;
42 
47  struct CurrentPeers {
50  };
51 
53  std::shared_ptr<transport::OdOsNotificationFactory> factory,
54  rxcpp::observable<CurrentPeers> peers,
55  logger::Logger log = logger::log("OnDemandConnectionManager"));
56 
58  std::shared_ptr<transport::OdOsNotificationFactory> factory,
59  rxcpp::observable<CurrentPeers> peers,
60  CurrentPeers initial_peers,
61  logger::Logger log = logger::log("OnDemandConnectionManager"));
62 
63  ~OnDemandConnectionManager() override;
64 
65  void onBatches(consensus::Round round, CollectionType batches) override;
66 
67  boost::optional<ProposalType> onRequestProposal(
68  consensus::Round round) override;
69 
70  private:
75  struct CurrentConnections {
77  };
78 
83  void initializeConnections(const CurrentPeers &peers);
84 
85  logger::Logger log_;
86  std::shared_ptr<transport::OdOsNotificationFactory> factory_;
87  rxcpp::composite_subscription subscription_;
88 
89  CurrentConnections connections_;
90 
91  std::shared_timed_mutex mutex_;
92  };
93 
94  } // namespace ordering
95 } // namespace iroha
96 
97 #endif // IROHA_ON_DEMAND_CONNECTION_MANAGER_HPP
Definition: on_demand_connection_manager.hpp:47
Definition: on_demand_connection_manager.hpp:36
~OnDemandConnectionManager() override
Definition: on_demand_connection_manager.cpp:38
Definition: on_demand_connection_manager.hpp:33
void onBatches(consensus::Round round, CollectionType batches) override
Definition: on_demand_connection_manager.cpp:42
OnDemandConnectionManager(std::shared_ptr< transport::OdOsNotificationFactory > factory, rxcpp::observable< CurrentPeers > peers, logger::Logger log=logger::log("OnDemandConnectionManager"))
Definition: on_demand_connection_manager.cpp:15
PeerType
Definition: on_demand_connection_manager.hpp:31
boost::optional< ProposalType > onRequestProposal(consensus::Round round) override
Definition: on_demand_connection_manager.cpp:75
Definition: on_demand_connection_manager.hpp:34
Definition: on_demand_connection_manager.hpp:22
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
std::array< T, kCount > PeerCollectionType
Collection with value types which represent peers.
Definition: on_demand_connection_manager.hpp:41
Definition: block_query.hpp:16
PeerCollectionType< std::shared_ptr< shared_model::interface::Peer > > peers
Definition: on_demand_connection_manager.hpp:49
Definition: on_demand_os_transport.hpp:31
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: on_demand_connection_manager.hpp:35
Definition: round.hpp:31
std::vector< TransactionBatchType > CollectionType
Definition: on_demand_os_transport.hpp:47