6 #ifndef IROHA_MST_STATE_HPP 7 #define IROHA_MST_STATE_HPP 10 #include <unordered_set> 12 #include <boost/bimap.hpp> 13 #include <boost/bimap/multiset_of.hpp> 14 #include <boost/bimap/unordered_multiset_of.hpp> 15 #include <boost/bimap/unordered_set_of.hpp> 16 #include <boost/optional/optional.hpp> 17 #include <boost/range/adaptor/map.hpp> 18 #include <boost/range/any_range.hpp> 47 const TimeType ¤t_time)
const = 0;
68 const TimeType ¤t_time)
const override;
71 std::chrono::minutes expiration_time_;
116 bool isEmpty()
const;
137 void eraseExpired(
const TimeType ¤t_time);
142 void eraseByTransactionHash(
150 bool contains(
const DataType &element)
const;
153 template <
typename Visitor>
155 const auto batches_range = batches_.right | boost::adaptors::map_keys;
156 std::for_each(batches_range.begin(), batches_range.end(), visitor);
160 template <
typename Visitor>
162 for (
const auto &batch : batches_.right | boost::adaptors::map_keys) {
163 std::for_each(batch->transactions().begin(),
164 batch->transactions().end(),
172 using BatchesForwardCollectionType = boost::
173 any_range<BatchPtr, boost::forward_traversal_tag, const BatchPtr &>;
175 using BatchesToHashBimap =
176 boost::bimap<boost::bimaps::unordered_set_of<
179 boost::bimaps::unordered_multiset_of<
181 iroha::model::PointerBatchHasher,
185 boost::bimap<boost::bimaps::multiset_of<
187 boost::bimaps::unordered_set_of<
189 iroha::model::PointerBatchHasher,
190 shared_model::interface::BatchHashEquality>>;
195 BatchesForwardCollectionType
const &batches,
210 void rawInsert(
const DataType &rhs_tx);
217 void extractExpiredImpl(
const TimeType ¤t_time,
218 boost::optional<MstState &> extracted);
224 BatchesBimap batches_;
225 BatchesToHashBimap batches_to_hash_;
232 #endif // IROHA_MST_STATE_HPP
crypto::Hash HashType
Type of hash.
Definition: types.hpp:34
virtual ~Completer()=default
Definition: transaction_batch.hpp:64
Definition: mst_state.hpp:76
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: mst_state.hpp:57
Definition: mst_state.hpp:31
void iterateBatches(const Visitor &visitor) const
Apply visitor to all batches.
Definition: mst_state.hpp:154
virtual bool isExpired(const DataType &batch, const TimeType ¤t_time) const =0
std::shared_ptr< const Completer > CompleterType
Definition: mst_state.hpp:74
Definition: block_query.hpp:15
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
shared_model::interface::types::TimestampType TimeType
Definition: mst_types.hpp:25
void iterateTransactions(const Visitor &visitor) const
Apply visitor to all transactions.
Definition: mst_state.hpp:161
Definition: mst_types.hpp:48
BatchPtr DataType
Definition: mst_types.hpp:41
bool contains(const CollectionType &haystack, const ElementType &needle)
Definition: yac.cpp:114
uint64_t TimestampType
Type of timestamp.
Definition: types.hpp:69
virtual bool isCompleted(const DataType &batch) const =0