hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
mst_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MST_STORAGE_HPP
7 #define IROHA_MST_STORAGE_HPP
8 
9 #include <mutex>
10 
12 #include "logger/logger_fwd.hpp"
15 
16 namespace iroha {
17 
23  class MstStorage {
24  public:
25  // ------------------------------| user API |-------------------------------
26 
35  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
36  const MstState &new_state);
37 
45 
51  MstState extractExpiredTransactions(const TimeType &current_time);
52 
60  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
61  const TimeType &current_time);
62 
69  MstState whatsNew(ConstRefState new_state) const;
70 
76  bool batchInStorage(const DataType &batch) const;
77 
78  virtual ~MstStorage() = default;
79 
80  protected:
81  // ------------------------------| class API |------------------------------
82 
86  explicit MstStorage(logger::LoggerPtr log);
87 
88  private:
89  virtual auto applyImpl(
90  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
91  const MstState &new_state)
92  -> decltype(apply(target_peer_key, new_state)) = 0;
93 
94  virtual auto updateOwnStateImpl(const DataType &tx)
95  -> decltype(updateOwnState(tx)) = 0;
96 
97  virtual auto extractExpiredTransactionsImpl(const TimeType &current_time)
98  -> decltype(extractExpiredTransactions(current_time)) = 0;
99 
100  virtual auto getDiffStateImpl(
101  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
102  const TimeType &current_time)
103  -> decltype(getDiffState(target_peer_key, current_time)) = 0;
104 
105  virtual auto whatsNewImpl(ConstRefState new_state) const
106  -> decltype(whatsNew(new_state)) = 0;
107 
108  virtual bool batchInStorageImpl(const DataType &batch) const = 0;
109 
110  // -------------------------------| fields |--------------------------------
111 
112  mutable std::mutex mutex_;
113 
114  protected:
116  };
117 } // namespace iroha
118 #endif // IROHA_MST_STORAGE_HPP
logger::LoggerPtr log_
Definition: mst_storage.hpp:115
StateUpdateResult apply(shared_model::interface::types::PublicKeyHexStringView target_peer_key, const MstState &new_state)
Definition: mst_storage.cpp:13
Definition: mst_storage.hpp:23
Definition: mst_state.hpp:76
StateUpdateResult updateOwnState(const DataType &tx)
Definition: mst_storage.cpp:20
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:15
virtual ~MstStorage()=default
shared_model::interface::types::TimestampType TimeType
Definition: mst_types.hpp:25
bool batchInStorage(const DataType &batch) const
Definition: mst_storage.cpp:43
Definition: mst_types.hpp:48
BatchPtr DataType
Definition: mst_types.hpp:41
MstStorage(logger::LoggerPtr log)
Definition: mst_storage.cpp:11
MstState whatsNew(ConstRefState new_state) const
Definition: mst_storage.cpp:38
MstState extractExpiredTransactions(const TimeType &current_time)
Definition: mst_storage.cpp:25
ConstRefT< MstState > ConstRefState
Definition: mst_types.hpp:39
MstState getDiffState(shared_model::interface::types::PublicKeyHexStringView target_peer_key, const TimeType &current_time)
Definition: mst_storage.cpp:31