mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: retrieve single pooled tx by hash (#6785)
This commit is contained in:
committed by
GitHub
parent
6930734a13
commit
be6d505745
@ -417,6 +417,10 @@ where
|
||||
self.pool.get_pooled_transaction_elements(tx_hashes, limit)
|
||||
}
|
||||
|
||||
fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option<PooledTransactionsElement> {
|
||||
self.pool.get_pooled_transaction_element(tx_hash)
|
||||
}
|
||||
|
||||
fn best_transactions(
|
||||
&self,
|
||||
) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
|
||||
|
||||
@ -135,6 +135,13 @@ impl TransactionPool for NoopTransactionPool {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_pooled_transaction_element(
|
||||
&self,
|
||||
_tx_hash: TxHash,
|
||||
) -> Option<PooledTransactionsElement> {
|
||||
None
|
||||
}
|
||||
|
||||
fn best_transactions(
|
||||
&self,
|
||||
) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
|
||||
|
||||
@ -341,6 +341,21 @@ where
|
||||
elements
|
||||
}
|
||||
|
||||
/// Returns converted [PooledTransactionsElement] for the given transaction hash.
|
||||
pub(crate) fn get_pooled_transaction_element(
|
||||
&self,
|
||||
tx_hash: TxHash,
|
||||
) -> Option<PooledTransactionsElement> {
|
||||
self.get(&tx_hash).and_then(|transaction| {
|
||||
let tx = transaction.to_recovered_transaction().into_signed();
|
||||
if tx.is_eip4844() {
|
||||
self.get_blob_transaction(tx).map(PooledTransactionsElement::BlobTransaction)
|
||||
} else {
|
||||
Some(PooledTransactionsElement::from(tx))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Updates the entire pool after a new block was executed.
|
||||
pub(crate) fn on_canonical_state_change(&self, update: CanonicalStateUpdate<'_>) {
|
||||
trace!(target: "txpool", ?update, "updating pool on canonical state change");
|
||||
|
||||
@ -221,6 +221,16 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
limit: GetPooledTransactionLimit,
|
||||
) -> Vec<PooledTransactionsElement>;
|
||||
|
||||
/// Returns converted [PooledTransactionsElement] for the given transaction hash.
|
||||
///
|
||||
/// This adheres to the expected behavior of
|
||||
/// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09):
|
||||
///
|
||||
/// If the transaction is a blob transaction, the sidecar will be included.
|
||||
///
|
||||
/// Consumer: P2P
|
||||
fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option<PooledTransactionsElement>;
|
||||
|
||||
/// Returns an iterator that yields transactions that are ready for block production.
|
||||
///
|
||||
/// Consumer: Block production
|
||||
|
||||
Reference in New Issue
Block a user