Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename transaction #4252

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ pub use crate::{
},
traits::{
AllPoolTransactions, BestTransactions, BlockInfo, CanonicalStateUpdate, ChangedAccount,
NewTransactionEvent, PendingTransactionListenerKind, PoolSize, PoolTransaction,
PooledTransaction, PropagateKind, PropagatedTransactions, TransactionOrigin,
TransactionPool, TransactionPoolExt,
EthPooledTransaction, NewTransactionEvent, PendingTransactionListenerKind, PoolSize,
PoolTransaction, PropagateKind, PropagatedTransactions, TransactionOrigin, TransactionPool,
TransactionPoolExt,
},
validate::{
EthTransactionValidator, TransactionValidationOutcome, TransactionValidator,
Expand Down Expand Up @@ -262,12 +262,15 @@ where
}

impl<Client>
Pool<EthTransactionValidator<Client, PooledTransaction>, CoinbaseTipOrdering<PooledTransaction>>
Pool<
EthTransactionValidator<Client, EthPooledTransaction>,
CoinbaseTipOrdering<EthPooledTransaction>,
>
where
Client: StateProviderFactory + Clone + 'static,
{
/// Returns a new [Pool] that uses the default [EthTransactionValidator] when validating
/// [PooledTransaction]s and ords via [CoinbaseTipOrdering]
/// [EthPooledTransaction]s and ords via [CoinbaseTipOrdering]
///
/// # Example
///
Expand All @@ -284,7 +287,7 @@ where
/// # }
/// ```
pub fn eth_pool(
validator: EthTransactionValidator<Client, PooledTransaction>,
validator: EthTransactionValidator<Client, EthPooledTransaction>,
config: PoolConfig,
) -> Self {
Self::new(validator, CoinbaseTipOrdering::default(), config)
Expand Down
12 changes: 6 additions & 6 deletions crates/transaction-pool/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use crate::{
error::PoolError, traits::PendingTransactionListenerKind, AllPoolTransactions,
AllTransactionsEvents, BestTransactions, BlockInfo, NewTransactionEvent, PoolResult, PoolSize,
PoolTransaction, PooledTransaction, PropagatedTransactions, TransactionEvents,
AllTransactionsEvents, BestTransactions, BlockInfo, EthPooledTransaction, NewTransactionEvent,
PoolResult, PoolSize, PoolTransaction, PropagatedTransactions, TransactionEvents,
TransactionOrigin, TransactionPool, TransactionValidationOutcome, TransactionValidator,
ValidPoolTransaction,
};
Expand All @@ -24,7 +24,7 @@ pub struct NoopTransactionPool;

#[async_trait::async_trait]
impl TransactionPool for NoopTransactionPool {
type Transaction = PooledTransaction;
type Transaction = EthPooledTransaction;

fn pool_size(&self) -> PoolSize {
Default::default()
Expand Down Expand Up @@ -212,16 +212,16 @@ impl<T> Default for MockTransactionValidator<T> {
#[derive(Debug, Clone, thiserror::Error)]
#[error("Can't insert transaction into the noop pool that does nothing.")]
pub struct NoopInsertError {
tx: PooledTransaction,
tx: EthPooledTransaction,
}

impl NoopInsertError {
fn new(tx: PooledTransaction) -> Self {
fn new(tx: EthPooledTransaction) -> Self {
Self { tx }
}

/// Returns the transaction that failed to be inserted.
pub fn into_inner(self) -> PooledTransaction {
pub fn into_inner(self) -> EthPooledTransaction {
self.tx
}
}
14 changes: 7 additions & 7 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,12 @@ pub trait PoolTransaction:
fn chain_id(&self) -> Option<u64>;
}

/// The default [PoolTransaction] for the [Pool](crate::Pool).
/// The default [PoolTransaction] for the [Pool](crate::Pool) for Ethereum.
///
/// This type is essentially a wrapper around [TransactionSignedEcRecovered] with additional fields
/// derived from the transaction that are frequently used by the pools for ordering.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PooledTransaction {
pub struct EthPooledTransaction {
/// EcRecovered transaction info
pub(crate) transaction: TransactionSignedEcRecovered,

Expand All @@ -580,7 +580,7 @@ pub struct PooledTransaction {
// TODO optional sidecar
}

impl PooledTransaction {
impl EthPooledTransaction {
/// Create new instance of [Self].
pub fn new(transaction: TransactionSignedEcRecovered) -> Self {
let gas_cost = match &transaction.transaction {
Expand All @@ -600,7 +600,7 @@ impl PooledTransaction {
}
}

impl PoolTransaction for PooledTransaction {
impl PoolTransaction for EthPooledTransaction {
/// Returns hash of the transaction.
fn hash(&self) -> &TxHash {
self.transaction.hash_ref()
Expand Down Expand Up @@ -696,13 +696,13 @@ impl PoolTransaction for PooledTransaction {
}
}

impl FromRecoveredTransaction for PooledTransaction {
impl FromRecoveredTransaction for EthPooledTransaction {
fn from_recovered_transaction(tx: TransactionSignedEcRecovered) -> Self {
PooledTransaction::new(tx)
EthPooledTransaction::new(tx)
}
}

impl IntoRecoveredTransaction for PooledTransaction {
impl IntoRecoveredTransaction for EthPooledTransaction {
fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered {
self.transaction.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions examples/network-txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
use reth_provider::test_utils::NoopProvider;
use reth_transaction_pool::{
CoinbaseTipOrdering, PoolTransaction, PooledTransaction, TransactionOrigin, TransactionPool,
CoinbaseTipOrdering, EthPooledTransaction, PoolTransaction, TransactionOrigin, TransactionPool,
TransactionValidationOutcome, TransactionValidator,
};

Expand Down Expand Up @@ -68,7 +68,7 @@ struct OkValidator;

#[async_trait::async_trait]
impl TransactionValidator for OkValidator {
type Transaction = PooledTransaction;
type Transaction = EthPooledTransaction;

async fn validate_transaction(
&self,
Expand Down
Loading