hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
pending_txs_storage_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_PENDING_TXS_STORAGE_IMPL_HPP
7 #define IROHA_PENDING_TXS_STORAGE_IMPL_HPP
8 
9 #include <set>
10 #include <shared_mutex>
11 #include <unordered_map>
12 #include <unordered_set>
13 
14 #include <rxcpp/rx.hpp>
17 
18 namespace iroha {
19 
20  class MstState;
21 
23  public:
29  using SharedState = std::shared_ptr<MstState>;
30  using SharedBatch = std::shared_ptr<TransactionBatch>;
31  using StateObservable = rxcpp::observable<SharedState>;
32  using BatchObservable = rxcpp::observable<SharedBatch>;
33 
35  BatchObservable prepared_batch,
36  BatchObservable expired_batch);
37 
39 
41  const AccountIdType &account_id) const override;
42 
43  private:
44  void updatedBatchesHandler(const SharedState &updated_batches);
45 
46  void removeBatch(const SharedBatch &batch);
47 
48  static std::set<AccountIdType> batchCreators(const TransactionBatch &batch);
49 
53  rxcpp::composite_subscription updated_batches_subscription_;
54  rxcpp::composite_subscription prepared_batch_subscription_;
55  rxcpp::composite_subscription expired_batch_subscription_;
56 
60  mutable std::shared_timed_mutex mutex_;
61 
71  struct {
72  std::unordered_map<AccountIdType,
73  std::unordered_set<HashType, HashType::Hasher>>
75  std::unordered_map<HashType,
76  std::shared_ptr<TransactionBatch>,
79  } storage_;
80  };
81 
82 } // namespace iroha
83 
84 #endif // IROHA_PENDING_TXS_STORAGE_IMPL_HPP
Definition: hash.hpp:18
std::unordered_map< AccountIdType, std::unordered_set< HashType, HashType::Hasher > > index
Definition: pending_txs_storage_impl.hpp:74
rxcpp::observable< SharedBatch > BatchObservable
Definition: pending_txs_storage_impl.hpp:32
crypto::Hash HashType
Type of hash.
Definition: types.hpp:33
shared_model::interface::types::AccountIdType AccountIdType
Definition: pending_txs_storage_impl.hpp:24
shared_model::interface::types::HashType HashType
Definition: pending_txs_storage_impl.hpp:25
shared_model::interface::types::SharedTxsCollectionType SharedTxsCollectionType
Definition: pending_txs_storage_impl.hpp:27
Definition: block_query.hpp:16
Definition: pending_txs_storage_impl.hpp:22
std::string AccountIdType
Type of account id.
Definition: types.hpp:37
SharedTxsCollectionType getPendingTransactions(const AccountIdType &account_id) const override
Definition: pending_txs_storage_impl.cpp:38
std::unordered_map< HashType, std::shared_ptr< TransactionBatch >, HashType::Hasher > batches
Definition: pending_txs_storage_impl.hpp:78
rxcpp::observable< SharedState > StateObservable
Definition: pending_txs_storage_impl.hpp:31
Definition: transaction_batch.hpp:22
std::shared_ptr< MstState > SharedState
Definition: pending_txs_storage_impl.hpp:29
Definition: hash.hpp:23
PendingTransactionStorageImpl(StateObservable updated_batches, BatchObservable prepared_batch, BatchObservable expired_batch)
Definition: pending_txs_storage_impl.cpp:13
Definition: pending_txs_storage.hpp:18
std::vector< std::shared_ptr< Transaction >> SharedTxsCollectionType
Definition: transaction_sequence_common.hpp:27
std::shared_ptr< TransactionBatch > SharedBatch
Definition: pending_txs_storage_impl.hpp:30
~PendingTransactionStorageImpl() override
Definition: pending_txs_storage_impl.cpp:31