File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
crates/transaction-pool/src Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,13 @@ where
212
212
fn get ( & self , tx_hash : & TxHash ) -> Option < Arc < ValidPoolTransaction < Self :: Transaction > > > {
213
213
self . inner ( ) . get ( tx_hash)
214
214
}
215
+
216
+ fn get_all (
217
+ & self ,
218
+ txs : impl IntoIterator < Item = TxHash > ,
219
+ ) -> Vec < Arc < ValidPoolTransaction < Self :: Transaction > > > {
220
+ self . inner ( ) . get_all ( txs)
221
+ }
215
222
}
216
223
217
224
impl < V : TransactionValidator , O : TransactionOrdering > Clone for Pool < V , O > {
Original file line number Diff line number Diff line change @@ -283,6 +283,16 @@ where
283
283
self . pool . read ( ) . get ( tx_hash)
284
284
}
285
285
286
+ /// Returns all the transactions belonging to the hashes.
287
+ ///
288
+ /// If no transaction exists, it is skipped.
289
+ pub ( crate ) fn get_all (
290
+ & self ,
291
+ txs : impl IntoIterator < Item = TxHash > ,
292
+ ) -> Vec < Arc < ValidPoolTransaction < T :: Transaction > > > {
293
+ self . pool . read ( ) . get_all ( txs) . collect ( )
294
+ }
295
+
286
296
/// Number of transactions in the entire pool
287
297
pub ( crate ) fn len ( & self ) -> usize {
288
298
self . pool . read ( ) . len ( )
Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ impl<T: TransactionOrdering> TxPool<T> {
123
123
self . all_transactions . by_hash . get ( tx_hash) . cloned ( )
124
124
}
125
125
126
+ /// Returns all transaction for the hashes, if it exis.
127
+ pub ( crate ) fn get_all < ' a > (
128
+ & ' a self ,
129
+ txs : impl IntoIterator < Item = TxHash > + ' a ,
130
+ ) -> impl Iterator < Item = Arc < ValidPoolTransaction < T :: Transaction > > > + ' a {
131
+ txs. into_iter ( ) . filter_map ( |tx| self . get ( & tx) )
132
+ }
133
+
126
134
/// Adds the transaction into the pool.
127
135
///
128
136
/// This pool consists of two three-pools: `Queued`, `Pending` and `BaseFee`.
Original file line number Diff line number Diff line change @@ -67,6 +67,16 @@ pub trait TransactionPool: Send + Sync {
67
67
68
68
/// Returns the transaction for the given hash.
69
69
fn get ( & self , tx_hash : & TxHash ) -> Option < Arc < ValidPoolTransaction < Self :: Transaction > > > ;
70
+
71
+ /// Returns all transactions objects for the given hashes.
72
+ ///
73
+ /// This adheres to the expected behavior of [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09):
74
+ /// The transactions must be in same order as in the request, but it is OK to skip transactions
75
+ /// which are not available.
76
+ fn get_all (
77
+ & self ,
78
+ txs : impl IntoIterator < Item = TxHash > ,
79
+ ) -> Vec < Arc < ValidPoolTransaction < Self :: Transaction > > > ;
70
80
}
71
81
72
82
/// Represents a new transaction
You can’t perform that action at this time.
0 commit comments