diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 5429798824..cd006c14c6 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -148,8 +148,8 @@ where T: TransactionOrdering::Transaction>, { /// Create a new transaction pool instance. - pub fn new(client: Arc, ordering: Arc, config: PoolConfig) -> Self { - Self { pool: Arc::new(PoolInner::new(client, ordering, config)) } + pub fn new(validator: V, ordering: T, config: PoolConfig) -> Self { + Self { pool: Arc::new(PoolInner::new(validator, ordering, config)) } } /// Returns the wrapped pool. @@ -302,7 +302,7 @@ where } } -impl Clone for Pool { +impl Clone for Pool { fn clone(&self) -> Self { Self { pool: Arc::clone(&self.pool) } } diff --git a/crates/transaction-pool/src/pool/best.rs b/crates/transaction-pool/src/pool/best.rs index 078e68a58a..ce68fc5d99 100644 --- a/crates/transaction-pool/src/pool/best.rs +++ b/crates/transaction-pool/src/pool/best.rs @@ -83,7 +83,7 @@ mod tests { #[test] fn test_best_iter() { - let mut pool = PendingPool::new(Arc::new(MockOrdering::default())); + let mut pool = PendingPool::new(MockOrdering::default()); let mut f = MockTransactionFactory::default(); let num_tx = 10; @@ -109,7 +109,7 @@ mod tests { #[test] fn test_best_iter_invalid() { - let mut pool = PendingPool::new(Arc::new(MockOrdering::default())); + let mut pool = PendingPool::new(MockOrdering::default()); let mut f = MockTransactionFactory::default(); let num_tx = 10; diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 1090feedff..bbcd5aa9d9 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -100,7 +100,7 @@ pub struct PoolInner { /// Internal mapping of addresses to plain ints. identifiers: RwLock, /// Transaction validation. - validator: Arc, + validator: V, /// The internal pool that manages all transactions. pool: RwLock>, /// Pool settings. @@ -115,13 +115,13 @@ pub struct PoolInner { // === impl PoolInner === -impl PoolInner +impl PoolInner where V: TransactionValidator, T: TransactionOrdering::Transaction>, { /// Create a new transaction pool instance. - pub(crate) fn new(validator: Arc, ordering: Arc, config: PoolConfig) -> Self { + pub(crate) fn new(validator: V, ordering: T, config: PoolConfig) -> Self { Self { identifiers: Default::default(), validator, diff --git a/crates/transaction-pool/src/pool/pending.rs b/crates/transaction-pool/src/pool/pending.rs index e5751c6877..1efdde6dec 100644 --- a/crates/transaction-pool/src/pool/pending.rs +++ b/crates/transaction-pool/src/pool/pending.rs @@ -22,7 +22,7 @@ use std::{ /// is also pending, then this will be moved to the `independent` queue. pub(crate) struct PendingPool { /// How to order transactions. - ordering: Arc, + ordering: T, /// Keeps track of transactions inserted in the pool. /// /// This way we can determine when transactions where submitted to the pool. @@ -46,7 +46,7 @@ pub(crate) struct PendingPool { impl PendingPool { /// Create a new pool instance. - pub(crate) fn new(ordering: Arc) -> Self { + pub(crate) fn new(ordering: T) -> Self { Self { ordering, submission_id: 0, diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index 41bbd959ff..5458d7ddc0 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -98,7 +98,7 @@ pub struct TxPool { impl TxPool { /// Create a new graph pool instance. - pub(crate) fn new(ordering: Arc, config: PoolConfig) -> Self { + pub(crate) fn new(ordering: T, config: PoolConfig) -> Self { Self { sender_info: Default::default(), pending_pool: PendingPool::new(ordering), diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index c9d1e5a239..348c184cd9 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -23,7 +23,7 @@ pub type MockValidTx = ValidPoolTransaction; /// Create an empty `TxPool` pub(crate) fn mock_tx_pool() -> MockTxPool { - MockTxPool::new(Arc::new(Default::default()), Default::default()) + MockTxPool::new(Default::default(), Default::default()) } /// Sets the value for the field diff --git a/crates/transaction-pool/src/test_utils/mod.rs b/crates/transaction-pool/src/test_utils/mod.rs index 7fd1da50bb..4a0d67534d 100644 --- a/crates/transaction-pool/src/test_utils/mod.rs +++ b/crates/transaction-pool/src/test_utils/mod.rs @@ -16,11 +16,7 @@ pub type TestPool = Pool, MockOrdering /// Returns a new [Pool] used for testing purposes pub fn testing_pool() -> TestPool { - Pool::new( - Arc::new(NoopTransactionValidator::default()), - Arc::new(MockOrdering::default()), - Default::default(), - ) + Pool::new(NoopTransactionValidator::default(), MockOrdering::default(), Default::default()) } // A [`TransactionValidator`] that does nothing. diff --git a/crates/transaction-pool/src/test_utils/pool.rs b/crates/transaction-pool/src/test_utils/pool.rs index 30217a8672..c8d79fb16e 100644 --- a/crates/transaction-pool/src/test_utils/pool.rs +++ b/crates/transaction-pool/src/test_utils/pool.rs @@ -41,7 +41,7 @@ impl MockPool { impl Default for MockPool { fn default() -> Self { - Self { pool: TxPool::new(Arc::new(MockOrdering::default()), Default::default()) } + Self { pool: TxPool::new(MockOrdering::default(), Default::default()) } } }