hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
mst_processor_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MST_PROCESSOR_IMPL_HPP
7 #define IROHA_MST_PROCESSOR_IMPL_HPP
8 
9 #include <memory>
11 #include "logger/logger_fwd.hpp"
17 
18 namespace iroha {
19 
26  public:
33  FairMstProcessor(std::shared_ptr<iroha::network::MstTransport> transport,
34  std::shared_ptr<MstStorage> storage,
35  std::shared_ptr<PropagationStrategy> strategy,
36  std::shared_ptr<MstTimeProvider> time_provider,
37  logger::LoggerPtr log);
38 
40 
41  // ------------------------| MstProcessor override |------------------------
42 
43  auto propagateBatchImpl(const DataType &batch)
44  -> decltype(propagateBatch(batch)) override;
45 
46  auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override;
47 
48  auto onPreparedBatchesImpl() const
49  -> decltype(onPreparedBatches()) override;
50 
51  auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override;
52 
53  bool batchInStorageImpl(const DataType &batch) const override;
54 
55  // ------------------| MstTransportNotification override |------------------
56 
58  MstState new_state) override;
59 
60  // ----------------------------| end override |-----------------------------
61 
62  private:
63  // -----------------------------| private api |-----------------------------
64 
69  void onPropagate(const PropagationStrategy::PropagationData &data);
70 
76  void completedBatchesNotify(ConstRefState state) const;
77 
83  void updatedBatchesNotify(ConstRefState state) const;
84 
89  void expiredBatchesNotify(ConstRefState state) const;
90 
91  // -------------------------------| fields |--------------------------------
92  std::shared_ptr<iroha::network::MstTransport> transport_;
93  std::shared_ptr<MstStorage> storage_;
94  std::shared_ptr<PropagationStrategy> strategy_;
95  std::shared_ptr<MstTimeProvider> time_provider_;
96 
97  // rx subjects
98 
100  rxcpp::subjects::subject<std::shared_ptr<MstState>> state_subject_;
101 
103  rxcpp::subjects::subject<DataType> batches_subject_;
104 
106  rxcpp::subjects::subject<DataType> expired_subject_;
107 
109 
110  rxcpp::composite_subscription propagation_subscriber_;
111 
112  logger::LoggerPtr log_;
113  };
114 } // namespace iroha
115 
116 #endif // IROHA_MST_PROCESSOR_IMPL_HPP
Definition: mst_processor_impl.hpp:24
std::vector< std::shared_ptr< shared_model::interface::Peer >> PropagationData
Definition: mst_propagation_strategy.hpp:22
FairMstProcessor(std::shared_ptr< iroha::network::MstTransport > transport, std::shared_ptr< MstStorage > storage, std::shared_ptr< PropagationStrategy > strategy, std::shared_ptr< MstTimeProvider > time_provider, logger::LoggerPtr log)
Definition: mst_processor_impl.cpp:13
Definition: mst_transport.hpp:19
bool batchInStorageImpl(const DataType &batch) const override
Definition: mst_processor_impl.cpp:82
Definition: mst_state.hpp:89
void onNewState(const shared_model::crypto::PublicKey &from, MstState new_state) override
Definition: mst_processor_impl.cpp:88
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
rxcpp::observable< DataType > onExpiredBatches() const
Definition: mst_processor.cpp:26
auto onPreparedBatchesImpl() const -> decltype(onPreparedBatches()) override
Definition: mst_processor_impl.cpp:48
Definition: block_query.hpp:14
auto propagateBatchImpl(const DataType &batch) -> decltype(propagateBatch(batch)) override
Definition: mst_processor_impl.cpp:34
void propagateBatch(const DataType &batch)
Definition: mst_processor.cpp:13
Definition: mst_processor.hpp:22
rxcpp::observable< std::shared_ptr< MstState > > onStateUpdate() const
Definition: mst_processor.cpp:17
auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override
Definition: mst_processor_impl.cpp:43
BatchPtr DataType
Definition: mst_types.hpp:40
Definition: public_key.hpp:16
rxcpp::observable< DataType > onPreparedBatches() const
Definition: mst_processor.cpp:22
auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override
Definition: mst_processor_impl.cpp:53
ConstRefT< MstState > ConstRefState
Definition: mst_types.hpp:38
~FairMstProcessor()
Definition: mst_processor_impl.cpp:28