Skip to content

Commit 0b3fc30

Browse files
authored
chore: add helper fn for building pool (#20100)
1 parent 3a9dbdc commit 0b3fc30

File tree

1 file changed

+35
-17
lines changed
  • crates/node/builder/src/components

1 file changed

+35
-17
lines changed

crates/node/builder/src/components/pool.rs

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use reth_chain_state::CanonStateSubscriptions;
66
use reth_chainspec::EthereumHardforks;
77
use reth_node_api::{NodeTypes, TxTy};
88
use reth_transaction_pool::{
9-
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, PoolConfig, PoolTransaction, SubPoolLimit,
10-
TransactionPool, TransactionValidationTaskExecutor, TransactionValidator,
9+
blobstore::DiskFileBlobStore, BlobStore, CoinbaseTipOrdering, PoolConfig, PoolTransaction,
10+
SubPoolLimit, TransactionPool, TransactionValidationTaskExecutor, TransactionValidator,
1111
};
1212
use std::{collections::HashSet, future::Future};
1313

@@ -133,31 +133,49 @@ where
133133
V::Transaction:
134134
PoolTransaction<Consensus = TxTy<Node::Types>> + reth_transaction_pool::EthPoolTransaction,
135135
{
136+
/// Consume the ype and build the [`reth_transaction_pool::Pool`] with the given config and blob
137+
/// store.
138+
pub fn build<BS>(
139+
self,
140+
blob_store: BS,
141+
pool_config: PoolConfig,
142+
) -> reth_transaction_pool::Pool<
143+
TransactionValidationTaskExecutor<V>,
144+
CoinbaseTipOrdering<V::Transaction>,
145+
BS,
146+
>
147+
where
148+
BS: BlobStore,
149+
{
150+
let TxPoolBuilder { validator, .. } = self;
151+
reth_transaction_pool::Pool::new(
152+
validator,
153+
CoinbaseTipOrdering::default(),
154+
blob_store,
155+
pool_config,
156+
)
157+
}
158+
136159
/// Build the transaction pool and spawn its maintenance tasks.
137160
/// This method creates the blob store, builds the pool, and spawns maintenance tasks.
138-
pub fn build_and_spawn_maintenance_task(
161+
pub fn build_and_spawn_maintenance_task<BS>(
139162
self,
140-
blob_store: DiskFileBlobStore,
163+
blob_store: BS,
141164
pool_config: PoolConfig,
142165
) -> eyre::Result<
143166
reth_transaction_pool::Pool<
144167
TransactionValidationTaskExecutor<V>,
145168
CoinbaseTipOrdering<V::Transaction>,
146-
DiskFileBlobStore,
169+
BS,
147170
>,
148-
> {
149-
// Destructure self to avoid partial move issues
150-
let TxPoolBuilder { ctx, validator, .. } = self;
151-
152-
let transaction_pool = reth_transaction_pool::Pool::new(
153-
validator,
154-
CoinbaseTipOrdering::default(),
155-
blob_store,
156-
pool_config.clone(),
157-
);
158-
171+
>
172+
where
173+
BS: BlobStore,
174+
{
175+
let ctx = self.ctx;
176+
let transaction_pool = self.build(blob_store, pool_config);
159177
// Spawn maintenance tasks using standalone functions
160-
spawn_maintenance_tasks(ctx, transaction_pool.clone(), &pool_config)?;
178+
spawn_maintenance_tasks(ctx, transaction_pool.clone(), transaction_pool.config())?;
161179

162180
Ok(transaction_pool)
163181
}

0 commit comments

Comments
 (0)