6 #ifndef IROHA_PENDING_TXS_STORAGE_IMPL_HPP 7 #define IROHA_PENDING_TXS_STORAGE_IMPL_HPP 14 #include <shared_mutex> 15 #include <unordered_map> 17 #include <boost/bimap.hpp> 18 #include <boost/bimap/unordered_multiset_of.hpp> 19 #include <boost/bimap/unordered_set_of.hpp> 20 #include <rxcpp/rx-lite.hpp> 31 struct private_tag {};
45 rxcpp::observable<PreparedTransactionDescriptor>;
55 static std::shared_ptr<PendingTransactionStorageImpl>
create(
68 const std::optional<shared_model::interface::types::HashType>
69 &first_tx_hash)
const override;
72 std::shared_ptr<ametsuchi::TxPresenceCache> &cache)
override;
75 void updatedBatchesHandler(
const SharedState &updated_batches);
81 void removeFromStorage(
const HashType &first_tx_hash,
82 const std::set<AccountIdType> &batch_creators,
91 std::weak_ptr<ametsuchi::TxPresenceCache> presence_cache_;
96 mutable std::shared_timed_mutex mutex_;
112 struct AccountBatches {
113 using BatchPtr = std::shared_ptr<TransactionBatch>;
114 using BatchesBimap = boost::bimap<
115 boost::bimaps::unordered_set_of<
HashType,
117 boost::bimaps::unordered_multiset_of<
122 std::list<BatchPtr> batches;
124 unordered_map<HashType, decltype(batches)::iterator, HashType::Hasher>
126 BatchesBimap txs_to_batches;
128 uint64_t all_transactions_quantity{0};
134 std::unordered_map<AccountIdType, AccountBatches> storage_;
139 #endif // IROHA_PENDING_TXS_STORAGE_IMPL_HPP
rxcpp::observable< SharedBatch > BatchObservable
Definition: pending_txs_storage_impl.hpp:42
crypto::Hash HashType
Type of hash.
Definition: types.hpp:34
shared_model::interface::types::AccountIdType AccountIdType
Definition: pending_txs_storage_impl.hpp:34
Definition: transaction_batch.hpp:64
Definition: result_fwd.hpp:27
PendingTransactionStorageImpl & operator=(PendingTransactionStorageImpl const &)=delete
shared_model::interface::types::HashType HashType
Definition: pending_txs_storage_impl.hpp:35
rxcpp::observable< PreparedTransactionDescriptor > PreparedTransactionsObservable
Definition: pending_txs_storage_impl.hpp:45
std::pair< AccountIdType, HashType > PreparedTransactionDescriptor
Definition: pending_txs_storage_impl.hpp:43
shared_model::interface::types::SharedTxsCollectionType SharedTxsCollectionType
Definition: pending_txs_storage_impl.hpp:37
Definition: block_query.hpp:15
Definition: pending_txs_storage_impl.hpp:29
std::string AccountIdType
Type of account id.
Definition: types.hpp:38
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
SharedTxsCollectionType getPendingTransactions(const AccountIdType &account_id) const override
Definition: pending_txs_storage_impl.cpp:84
PendingTransactionStorageImpl(PendingTransactionStorageImpl::private_tag)
Definition: pending_txs_storage_impl.cpp:14
rxcpp::observable< SharedState > StateObservable
Definition: pending_txs_storage_impl.hpp:41
Definition: transaction_batch.hpp:22
std::shared_ptr< MstState > SharedState
Definition: pending_txs_storage_impl.hpp:39
std::vector< std::shared_ptr< Transaction > > SharedTxsCollectionType
Definition: transaction_sequence_common.hpp:27
void insertPresenceCache(std::shared_ptr< ametsuchi::TxPresenceCache > &cache) override
Definition: pending_txs_storage_impl.cpp:222
uint16_t TransactionsNumberType
Type of a number of transactions in block and query response page.
Definition: types.hpp:84
static std::shared_ptr< PendingTransactionStorageImpl > create(StateObservable updated_batches, BatchObservable prepared_batch, BatchObservable expired_batch, PreparedTransactionsObservable prepared_txs, FinalizedTransactionsObservable finalized_txs)
Definition: pending_txs_storage_impl.cpp:18
rxcpp::observable< HashType > FinalizedTransactionsObservable
Definition: pending_txs_storage_impl.hpp:46
std::shared_ptr< shared_model::interface::TransactionBatch > BatchPtr
Definition: mst_types.hpp:23
Definition: pending_txs_storage.hpp:22
std::shared_ptr< TransactionBatch > SharedBatch
Definition: pending_txs_storage_impl.hpp:40