Skip to content

Commit f8b678c

Browse files
authored
perf: specialize single batch request (paradigmxyz#18289)
1 parent d99f37b commit f8b678c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎crates/transaction-pool/src/batcher.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,19 @@ where
6565
(processor, request_tx)
6666
}
6767

68+
async fn process_request(pool: &Pool, req: BatchTxRequest<Pool::Transaction>) {
69+
let BatchTxRequest { pool_tx, response_tx } = req;
70+
let pool_result = pool.add_transaction(TransactionOrigin::Local, pool_tx).await;
71+
let _ = response_tx.send(pool_result);
72+
}
73+
6874
/// Process a batch of transaction requests, grouped by origin
69-
async fn process_batch(pool: &Pool, batch: Vec<BatchTxRequest<Pool::Transaction>>) {
75+
async fn process_batch(pool: &Pool, mut batch: Vec<BatchTxRequest<Pool::Transaction>>) {
76+
if batch.len() == 1 {
77+
Self::process_request(pool, batch.remove(0)).await;
78+
return
79+
}
80+
7081
let (pool_transactions, response_tx): (Vec<_>, Vec<_>) =
7182
batch.into_iter().map(|req| (req.pool_tx, req.response_tx)).unzip();
7283

0 commit comments

Comments
 (0)