Skip to content

Commit 22badc8

Browse files
feat: Extend Maybeconditional with helper fn (#14511)
1 parent cb615cf commit 22badc8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/optimism/txpool/src/conditional.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Additional support for pooled transactions with [`TransactionConditional`]
22
3+
use alloy_consensus::conditional::BlockConditionalAttributes;
34
use alloy_rpc_types_eth::erc4337::TransactionConditional;
45

56
/// Helper trait that allows attaching a [`TransactionConditional`].
@@ -10,6 +11,11 @@ pub trait MaybeConditionalTransaction {
1011
/// Get attached [`TransactionConditional`] if any.
1112
fn conditional(&self) -> Option<&TransactionConditional>;
1213

14+
/// Check if the conditional has exceeded the block attributes.
15+
fn has_exceeded_block_attributes(&self, block_attr: &BlockConditionalAttributes) -> bool {
16+
self.conditional().map(|tc| tc.has_exceeded_block_attributes(block_attr)).unwrap_or(false)
17+
}
18+
1319
/// Helper that sets the conditional and returns the instance again
1420
fn with_conditional(mut self, conditional: TransactionConditional) -> Self
1521
where

crates/optimism/txpool/src/maintain.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ where
4747
};
4848
let mut to_remove = Vec::new();
4949
for tx in &pool.pooled_transactions() {
50-
if let Some(conditional) = tx.transaction.conditional() {
51-
if conditional.has_exceeded_block_attributes(&block_attr) {
52-
to_remove.push(*tx.hash());
53-
}
50+
if tx.transaction.has_exceeded_block_attributes(&block_attr) {
51+
to_remove.push(*tx.hash());
5452
}
5553
}
5654
let _ = pool.remove_transactions(to_remove);

0 commit comments

Comments
 (0)