Skip to content

Commit 2ad29d9

Browse files
mattsselwedge99
authored andcommitted
chore: introduce validationtask with capacity (paradigmxyz#18291)
1 parent fe1e451 commit 2ad29d9

File tree

1 file changed

+9
-2
lines changed
  • crates/transaction-pool/src/validate

1 file changed

+9
-2
lines changed

crates/transaction-pool/src/validate/task.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ pub struct ValidationTask {
3434
}
3535

3636
impl ValidationTask {
37-
/// Creates a new cloneable task pair
37+
/// Creates a new cloneable task pair.
38+
///
39+
/// The sender sends new (transaction) validation tasks to an available validation task.
3840
pub fn new() -> (ValidationJobSender, Self) {
39-
let (tx, rx) = mpsc::channel(1);
41+
Self::with_capacity(1)
42+
}
43+
44+
/// Creates a new cloneable task pair with the given channel capacity.
45+
pub fn with_capacity(capacity: usize) -> (ValidationJobSender, Self) {
46+
let (tx, rx) = mpsc::channel(capacity);
4047
let metrics = TxPoolValidatorMetrics::default();
4148
(ValidationJobSender { tx, metrics }, Self::with_receiver(rx))
4249
}

0 commit comments

Comments
 (0)