chore(txpool): add IntoRecoveredTransaction to PoolTransaction (#1750)

This commit is contained in:
Matthias Seitz
2023-03-14 11:14:32 +01:00
committed by GitHub
parent c3a49aea72
commit 6c12ccb6e1
2 changed files with 12 additions and 3 deletions

View File

@@ -250,7 +250,9 @@ impl<T> BestTransactions for std::iter::Empty<T> {
}
/// Trait for transaction types used inside the pool
pub trait PoolTransaction: fmt::Debug + Send + Sync + FromRecoveredTransaction {
pub trait PoolTransaction:
fmt::Debug + Send + Sync + FromRecoveredTransaction + IntoRecoveredTransaction
{
/// Hash of the transaction.
fn hash(&self) -> &TxHash;

View File

@@ -7,8 +7,9 @@ use crate::{
MAX_INIT_CODE_SIZE, TX_MAX_SIZE,
};
use reth_primitives::{
Address, InvalidTransactionError, TransactionKind, TxHash, EIP1559_TX_TYPE_ID,
EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U256,
Address, IntoRecoveredTransaction, InvalidTransactionError, TransactionKind,
TransactionSignedEcRecovered, TxHash, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
LEGACY_TX_TYPE_ID, U256,
};
use reth_provider::AccountProvider;
use std::{fmt, time::Instant};
@@ -330,6 +331,12 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
}
}
impl<T: PoolTransaction> IntoRecoveredTransaction for ValidPoolTransaction<T> {
fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered {
self.transaction.to_recovered_transaction()
}
}
#[cfg(test)]
impl<T: PoolTransaction + Clone> Clone for ValidPoolTransaction<T> {
fn clone(&self) -> Self {