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 
80 
81  virtual ~MstStorage() = default;
82 
83  protected:
84  // ------------------------------| class API |------------------------------
85 
89  explicit MstStorage(logger::LoggerPtr log);
90 
91  private:
92  virtual auto applyImpl(
93  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
94  const MstState &new_state)
95  -> decltype(apply(target_peer_key, new_state)) = 0;
96 
97  virtual auto updateOwnStateImpl(const DataType &tx)
98  -> decltype(updateOwnState(tx)) = 0;
99 
100  virtual auto extractExpiredTransactionsImpl(const TimeType &current_time)
101  -> decltype(extractExpiredTransactions(current_time)) = 0;
102 
103  virtual auto getDiffStateImpl(
104  shared_model::interface::types::PublicKeyHexStringView target_peer_key,
105  const TimeType &current_time)
106  -> decltype(getDiffState(target_peer_key, current_time)) = 0;
107 
108  virtual auto whatsNewImpl(ConstRefState new_state) const
109  -> decltype(whatsNew(new_state)) = 0;
110 
111  virtual bool batchInStorageImpl(const DataType &batch) const = 0;
112 
113  virtual void processFinalizedTransactionImpl(
115 
116  // -------------------------------| fields |--------------------------------
117 
118  mutable std::mutex mutex_;
119 
120  protected:
122  };
123 } // namespace iroha
124 #endif // IROHA_MST_STORAGE_HPP
Definition: hash.hpp:18
logger::LoggerPtr log_
Definition: mst_storage.hpp:121
StateUpdateResult apply(shared_model::interface::types::PublicKeyHexStringView target_peer_key, const MstState &new_state)
Definition: mst_storage.cpp:13
Definition: mst_storage.hpp:23
void processFinalizedTransaction(shared_model::interface::types::HashType const &hash)
Definition: mst_storage.cpp:47
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
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
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