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>
15 #include "logger/logger_fwd.hpp"
19 
20 namespace iroha {
21 
28  public:
35  FairMstProcessor(std::shared_ptr<iroha::network::MstTransport> transport,
36  std::shared_ptr<MstStorage> storage,
37  std::shared_ptr<PropagationStrategy> strategy,
38  std::shared_ptr<MstTimeProvider> time_provider,
39  logger::LoggerPtr log);
40 
42 
43  // ------------------------| MstProcessor override |------------------------
44 
45  auto propagateBatchImpl(const DataType &batch)
46  -> decltype(propagateBatch(batch)) override;
47 
48  auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override;
49 
50  auto onPreparedBatchesImpl() const
51  -> decltype(onPreparedBatches()) override;
52 
53  auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override;
54 
55  bool batchInStorageImpl(const DataType &batch) const override;
56 
57  // ------------------| MstTransportNotification override |------------------
58 
59  void onNewState(shared_model::interface::types::PublicKeyHexStringView from,
60  MstState &&new_state) override;
61 
62  // ----------------------------| end override |-----------------------------
63 
64  private:
65  // -----------------------------| private api |-----------------------------
66 
72  void completedBatchesNotify(ConstRefState state) const;
73 
79  void updatedBatchesNotify(ConstRefState state) const;
80 
85  void expiredBatchesNotify(ConstRefState state) const;
86 
87  // -------------------------------| fields |--------------------------------
88  logger::LoggerPtr log_;
89 
90  std::shared_ptr<iroha::network::MstTransport> transport_;
91  std::shared_ptr<MstStorage> storage_;
92  std::shared_ptr<PropagationStrategy> strategy_;
93  std::shared_ptr<MstTimeProvider> time_provider_;
94 
95  // rx subjects
96 
98  rxcpp::subjects::subject<std::shared_ptr<MstState>> state_subject_;
99 
101  rxcpp::subjects::subject<DataType> batches_subject_;
102 
104  rxcpp::subjects::subject<DataType> expired_subject_;
105 
107 
108  rxcpp::composite_subscription propagation_subscriber_;
109  };
110 } // namespace iroha
111 
112 #endif // IROHA_MST_PROCESSOR_IMPL_HPP
Definition: mst_processor_impl.hpp:26
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:78
Definition: mst_transport.hpp:24
bool batchInStorageImpl(const DataType &batch) const override
Definition: mst_processor_impl.cpp:131
rxcpp::observable< DataType > onPreparedBatches() const
Definition: mst_processor.cpp:23
Definition: mst_state.hpp:76
rxcpp::observable< DataType > onExpiredBatches() const
Definition: mst_processor.cpp:27
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
auto onPreparedBatchesImpl() const -> decltype(onPreparedBatches()) override
Definition: mst_processor_impl.cpp:121
rxcpp::observable< std::shared_ptr< MstState > > onStateUpdate() const
Definition: mst_processor.cpp:18
Definition: block_query.hpp:15
auto propagateBatchImpl(const DataType &batch) -> decltype(propagateBatch(batch)) override
Definition: mst_processor_impl.cpp:107
void propagateBatch(const DataType &batch)
Definition: mst_processor.cpp:14
Definition: mst_processor.hpp:22
auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override
Definition: mst_processor_impl.cpp:116
void onNewState(shared_model::interface::types::PublicKeyHexStringView from, MstState &&new_state) override
Definition: mst_processor_impl.cpp:137
BatchPtr DataType
Definition: mst_types.hpp:41
auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override
Definition: mst_processor_impl.cpp:126
ConstRefT< MstState > ConstRefState
Definition: mst_types.hpp:39
~FairMstProcessor()
Definition: mst_processor_impl.cpp:101