Kagome
Polkadot Runtime Engine in C++17
transaction_pool.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_TRANSACTION_POOL_HPP
7 #define KAGOME_TRANSACTION_POOL_HPP
8 
9 #include <outcome/outcome.hpp>
10 
11 #include "primitives/block_id.hpp"
14 
15 namespace kagome::transaction_pool {
16 
17  using primitives::Transaction;
18 
20  public:
21  struct Status;
22  struct Limits;
23 
24  virtual ~TransactionPool() = default;
25 
29  virtual const std::unordered_map<Transaction::Hash,
30  std::shared_ptr<Transaction>>
31  &getPendingTransactions() const = 0;
32 
42  virtual outcome::result<Transaction::Hash> submitExtrinsic(
44  primitives::Extrinsic extrinsic) = 0;
45 
54  virtual outcome::result<void> submitOne(Transaction &&tx) = 0;
55 
61  virtual outcome::result<Transaction> removeOne(
62  const Transaction::Hash &txHash) = 0;
63 
67  virtual std::map<Transaction::Hash, std::shared_ptr<Transaction>>
68  getReadyTransactions() const = 0;
69 
78  virtual outcome::result<std::vector<Transaction>> removeStale(
79  const primitives::BlockId &at) = 0;
80 
81  virtual Status getStatus() const = 0;
82 
83  virtual outcome::result<primitives::Transaction> constructTransaction(
85  primitives::Extrinsic extrinsic) const = 0;
86  };
87 
89  size_t ready_num;
90  size_t waiting_num;
91  };
92 
94  static constexpr size_t kDefaultMaxReadyNum = 128;
95  static constexpr size_t kDefaultCapacity = 512;
96 
97  size_t max_ready_num = kDefaultMaxReadyNum;
98  size_t capacity = kDefaultCapacity;
99  };
100 
101 } // namespace kagome::transaction_pool
102 
103 #endif // KAGOME_TRANSACTION_POOL_HPP
virtual outcome::result< Transaction::Hash > submitExtrinsic(primitives::TransactionSource source, primitives::Extrinsic extrinsic)=0
virtual Status getStatus() const =0
virtual outcome::result< void > submitOne(Transaction &&tx)=0
common::Hash256 Hash
virtual outcome::result< std::vector< Transaction > > removeStale(const primitives::BlockId &at)=0
virtual std::map< Transaction::Hash, std::shared_ptr< Transaction > > getReadyTransactions() const =0
virtual outcome::result< Transaction > removeOne(const Transaction::Hash &txHash)=0
virtual const std::unordered_map< Transaction::Hash, std::shared_ptr< Transaction > > & getPendingTransactions() const =0
boost::variant< BlockHash, BlockNumber > BlockId
Block id is the variant over BlockHash and BlockNumber.
Definition: block_id.hpp:18
Extrinsic class represents extrinsic.
Definition: extrinsic.hpp:24
virtual outcome::result< primitives::Transaction > constructTransaction(primitives::TransactionSource source, primitives::Extrinsic extrinsic) const =0