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.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 
39 
40  // ------------------------| MstProcessor override |------------------------
41 
42  auto propagateBatchImpl(const DataType &batch)
43  -> decltype(propagateBatch(batch)) override;
44 
45  auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override;
46 
47  auto onPreparedBatchesImpl() const
48  -> decltype(onPreparedBatches()) override;
49 
50  auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override;
51 
52  bool batchInStorageImpl(const DataType &batch) const override;
53 
54  // ------------------| MstTransportNotification override |------------------
55 
57  ConstRefState new_state) override;
58 
59  // ----------------------------| end override |-----------------------------
60 
61  private:
62  // -----------------------------| private api |-----------------------------
63 
68  void onPropagate(const PropagationStrategy::PropagationData &data);
69 
75  void completedBatchesNotify(ConstRefState state) const;
76 
82  void updatedBatchesNotify(ConstRefState state) const;
83 
88  void expiredBatchesNotify(ConstRefState state) const;
89 
90  // -------------------------------| fields |--------------------------------
91  std::shared_ptr<iroha::network::MstTransport> transport_;
92  std::shared_ptr<MstStorage> storage_;
93  std::shared_ptr<PropagationStrategy> strategy_;
94  std::shared_ptr<MstTimeProvider> time_provider_;
95 
96  // rx subjects
97 
99  rxcpp::subjects::subject<std::shared_ptr<MstState>> state_subject_;
100 
102  rxcpp::subjects::subject<DataType> batches_subject_;
103 
105  rxcpp::subjects::subject<DataType> expired_subject_;
106 
108 
109  rxcpp::composite_subscription propagation_subscriber_;
110  };
111 } // namespace iroha
112 
113 #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
Definition: mst_transport.hpp:19
bool batchInStorageImpl(const DataType &batch) const override
Definition: mst_processor_impl.cpp:85
FairMstProcessor(std::shared_ptr< iroha::network::MstTransport > transport, std::shared_ptr< MstStorage > storage, std::shared_ptr< PropagationStrategy > strategy, std::shared_ptr< MstTimeProvider > time_provider)
Definition: mst_processor_impl.cpp:12
rxcpp::observable< DataType > onExpiredBatches() const
Definition: mst_processor.cpp:25
auto onPreparedBatchesImpl() const -> decltype(onPreparedBatches()) override
Definition: mst_processor_impl.cpp:45
Definition: block_query.hpp:16
auto propagateBatchImpl(const DataType &batch) -> decltype(propagateBatch(batch)) override
Definition: mst_processor_impl.cpp:31
void propagateBatch(const DataType &batch)
Definition: mst_processor.cpp:12
Definition: mst_processor.hpp:22
rxcpp::observable< std::shared_ptr< MstState > > onStateUpdate() const
Definition: mst_processor.cpp:16
auto onStateUpdateImpl() const -> decltype(onStateUpdate()) override
Definition: mst_processor_impl.cpp:40
void onNewState(const shared_model::crypto::PublicKey &from, ConstRefState new_state) override
Definition: mst_processor_impl.cpp:91
BatchPtr DataType
Definition: mst_types.hpp:40
Definition: public_key.hpp:16
rxcpp::observable< DataType > onPreparedBatches() const
Definition: mst_processor.cpp:21
auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override
Definition: mst_processor_impl.cpp:50
ConstRefT< MstState > ConstRefState
Definition: mst_types.hpp:38
~FairMstProcessor()
Definition: mst_processor_impl.cpp:25