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 
11 
12 #include <memory>
13 
14 #include <rxcpp/rx-lite.hpp>
16 #include "logger/logger_fwd.hpp"
20 
21 namespace iroha {
22 
29  public:
36  FairMstProcessor(std::shared_ptr<iroha::network::MstTransport> transport,
37  std::shared_ptr<MstStorage> storage,
38  std::shared_ptr<PropagationStrategy> strategy,
39  std::shared_ptr<MstTimeProvider> time_provider,
40  logger::LoggerPtr log);
41 
43 
44  // ------------------------| MstProcessor override |------------------------
45 
46  auto propagateBatchImpl(const DataType &batch)
47  -> decltype(propagateBatch(batch)) override;
48 
49  auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override;
50 
51  auto onPreparedBatchesImpl() const
52  -> decltype(onPreparedBatches()) override;
53 
54  auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override;
55 
56  bool batchInStorageImpl(const DataType &batch) const override;
57 
58  // ------------------| MstTransportNotification override |------------------
59 
61  MstState new_state) override;
62 
63  // ----------------------------| end override |-----------------------------
64 
65  private:
66  // -----------------------------| private api |-----------------------------
67 
72  void onPropagate(const PropagationStrategy::PropagationData &data);
73 
79  void completedBatchesNotify(ConstRefState state) const;
80 
86  void updatedBatchesNotify(ConstRefState state) const;
87 
92  void expiredBatchesNotify(ConstRefState state) const;
93 
94  // -------------------------------| fields |--------------------------------
95  std::shared_ptr<iroha::network::MstTransport> transport_;
96  std::shared_ptr<MstStorage> storage_;
97  std::shared_ptr<PropagationStrategy> strategy_;
98  std::shared_ptr<MstTimeProvider> time_provider_;
99 
100  // rx subjects
101 
103  rxcpp::subjects::subject<std::shared_ptr<MstState>> state_subject_;
104 
106  rxcpp::subjects::subject<DataType> batches_subject_;
107 
109  rxcpp::subjects::subject<DataType> expired_subject_;
110 
112 
113  rxcpp::composite_subscription propagation_subscriber_;
114 
115  logger::LoggerPtr log_;
116  };
117 } // namespace iroha
118 
119 #endif // IROHA_MST_PROCESSOR_IMPL_HPP
Definition: mst_processor_impl.hpp:27
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:27
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:14
Definition: mst_processor.hpp:22
rxcpp::observable< std::shared_ptr< MstState > > onStateUpdate() const
Definition: mst_processor.cpp:18
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:23
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