chore(transaction-pool): make NoopTransactionPool generic over EthPoolTransaction (#15923)

This commit is contained in:
cakevm
2025-04-25 11:51:51 +02:00
committed by GitHub
parent fab0d81a97
commit 5810f31b6c

View File

@@ -28,12 +28,28 @@ use tokio::sync::{mpsc, mpsc::Receiver};
///
/// All transactions are rejected and no events are emitted.
/// This type will never hold any transactions and is only useful for wiring components together.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct NoopTransactionPool;
pub struct NoopTransactionPool<T: EthPoolTransaction = EthPooledTransaction> {
/// Type marker
_marker: PhantomData<T>,
}
impl TransactionPool for NoopTransactionPool {
type Transaction = EthPooledTransaction;
impl<T: EthPoolTransaction> NoopTransactionPool<T> {
/// Creates a new [`NoopTransactionPool`].
pub fn new() -> Self {
Self { _marker: Default::default() }
}
}
impl Default for NoopTransactionPool<EthPooledTransaction> {
fn default() -> Self {
Self { _marker: Default::default() }
}
}
impl<T: EthPoolTransaction> TransactionPool for NoopTransactionPool<T> {
type Transaction = T;
fn pool_size(&self) -> PoolSize {
Default::default()
@@ -375,17 +391,17 @@ impl<T> Default for MockTransactionValidator<T> {
/// An error that contains the transaction that failed to be inserted into the noop pool.
#[derive(Debug, Clone, thiserror::Error)]
#[error("can't insert transaction into the noop pool that does nothing")]
pub struct NoopInsertError {
tx: EthPooledTransaction,
pub struct NoopInsertError<T: EthPoolTransaction = EthPooledTransaction> {
tx: T,
}
impl NoopInsertError {
const fn new(tx: EthPooledTransaction) -> Self {
impl<T: EthPoolTransaction> NoopInsertError<T> {
const fn new(tx: T) -> Self {
Self { tx }
}
/// Returns the transaction that failed to be inserted.
pub fn into_inner(self) -> EthPooledTransaction {
pub fn into_inner(self) -> T {
self.tx
}
}