mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
tx-pool: Make txpool independent of primitive tx types (#9916)
This commit is contained in:
@ -59,8 +59,8 @@ pub use reth_primitives_traits::{
|
||||
pub use static_file::StaticFileSegment;
|
||||
|
||||
pub use transaction::{
|
||||
BlobTransaction, BlobTransactionSidecar, FromRecoveredPooledTransaction,
|
||||
PooledTransactionsElement, PooledTransactionsElementEcRecovered,
|
||||
BlobTransaction, BlobTransactionSidecar, PooledTransactionsElement,
|
||||
PooledTransactionsElementEcRecovered,
|
||||
};
|
||||
|
||||
#[cfg(feature = "c-kzg")]
|
||||
@ -70,9 +70,9 @@ pub use transaction::{
|
||||
util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message},
|
||||
AccessList, AccessListItem, IntoRecoveredTransaction, InvalidTransactionError, Signature,
|
||||
Transaction, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered,
|
||||
TransactionSignedNoHash, TryFromRecoveredTransaction, TxEip1559, TxEip2930, TxEip4844,
|
||||
TxEip7702, TxHashOrNumber, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
|
||||
EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
TransactionSignedNoHash, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxHashOrNumber, TxLegacy,
|
||||
TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
|
||||
LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
|
||||
// Re-exports
|
||||
|
||||
@ -1580,48 +1580,7 @@ impl Decodable for TransactionSignedEcRecovered {
|
||||
}
|
||||
}
|
||||
|
||||
/// A transaction type that can be created from a [`TransactionSignedEcRecovered`] transaction.
|
||||
///
|
||||
/// This is a conversion trait that'll ensure transactions received via P2P can be converted to the
|
||||
/// transaction type that the transaction pool uses.
|
||||
pub trait TryFromRecoveredTransaction {
|
||||
/// The error type returned by the transaction.
|
||||
type Error;
|
||||
/// Converts to this type from the given [`TransactionSignedEcRecovered`].
|
||||
fn try_from_recovered_transaction(
|
||||
tx: TransactionSignedEcRecovered,
|
||||
) -> Result<Self, Self::Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
// Noop conversion
|
||||
impl TryFromRecoveredTransaction for TransactionSignedEcRecovered {
|
||||
type Error = TryFromRecoveredTransactionError;
|
||||
|
||||
#[inline]
|
||||
fn try_from_recovered_transaction(
|
||||
tx: TransactionSignedEcRecovered,
|
||||
) -> Result<Self, Self::Error> {
|
||||
if tx.is_eip4844() {
|
||||
Err(TryFromRecoveredTransactionError::BlobSidecarMissing)
|
||||
} else {
|
||||
Ok(tx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A transaction type that can be created from a [`PooledTransactionsElementEcRecovered`]
|
||||
/// transaction.
|
||||
///
|
||||
/// This is a conversion trait that'll ensure transactions received via P2P can be converted to the
|
||||
/// transaction type that the transaction pool uses.
|
||||
pub trait FromRecoveredPooledTransaction {
|
||||
/// Converts to this type from the given [`PooledTransactionsElementEcRecovered`].
|
||||
fn from_recovered_pooled_transaction(tx: PooledTransactionsElementEcRecovered) -> Self;
|
||||
}
|
||||
|
||||
/// The inverse of [`TryFromRecoveredTransaction`] that ensure the transaction can be sent over the
|
||||
/// Ensures the transaction can be sent over the
|
||||
/// network
|
||||
pub trait IntoRecoveredTransaction {
|
||||
/// Converts to this type into a [`TransactionSignedEcRecovered`].
|
||||
|
||||
Reference in New Issue
Block a user