hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
gossip_propagation_strategy.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_GOSSIP_PROPAGATION_STRATEGY_HPP
7 #define IROHA_GOSSIP_PROPAGATION_STRATEGY_HPP
8 
9 #include <boost/optional.hpp>
10 #include <chrono>
11 #include <mutex>
12 
13 #include <rxcpp/rx-lite.hpp>
17 
18 #include <rxcpp/operators/rx-observe_on.hpp>
19 
20 namespace iroha {
21 
29  public:
30  using PeerProviderFactory = std::shared_ptr<ametsuchi::PeerQueryFactory>;
31  using OptPeer = boost::optional<PropagationData::value_type>;
39  // TODO 30.01.2019 lebdron: IR-266 Remove PeerQueryFactory
40  PeerProviderFactory peer_factory,
41  rxcpp::observe_on_one_worker emit_worker,
42  const GossipPropagationStrategyParams &params);
43 
45 
46  // ------------------| PropagationStrategy override |------------------
47 
48  rxcpp::observable<PropagationData> emitter() override;
49 
50  // --------------------------| end override |---------------------------
51  private:
55  PeerProviderFactory peer_factory;
56 
60  PropagationData last_data;
61 
65  std::vector<size_t> non_visited;
66 
70  rxcpp::observe_on_one_worker emit_worker;
71 
72  /*
73  * Observable for the emitting propagated data
74  */
75  rxcpp::observable<PropagationData> emitent;
76 
77  /*
78  * Mutex for handling observable stopping
79  */
80  std::mutex m;
81 
86  bool initQueue();
87 
92  OptPeer visit();
93  };
94 } // namespace iroha
95 
96 #endif // IROHA_GOSSIP_PROPAGATION_STRATEGY_HPP
Definition: mst_propagation_strategy.hpp:18
boost::optional< PropagationData::value_type > OptPeer
Definition: gossip_propagation_strategy.hpp:31
GossipPropagationStrategy(PeerProviderFactory peer_factory, rxcpp::observe_on_one_worker emit_worker, const GossipPropagationStrategyParams &params)
Definition: gossip_propagation_strategy.cpp:23
Definition: block_query.hpp:14
~GossipPropagationStrategy()
Definition: gossip_propagation_strategy.cpp:50
rxcpp::observable< PropagationData > emitter() override
Definition: gossip_propagation_strategy.cpp:46
Definition: gossip_propagation_strategy.hpp:28
Definition: gossip_propagation_strategy_params.hpp:23
std::shared_ptr< ametsuchi::PeerQueryFactory > PeerProviderFactory
Definition: gossip_propagation_strategy.hpp:30
PropagationStrategy::PropagationData PropagationData
Definition: gossip_propagation_strategy.cpp:18