mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Extend Maybeconditional with helper fn (#14511)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
//! Additional support for pooled transactions with [`TransactionConditional`]
|
||||
|
||||
use alloy_consensus::conditional::BlockConditionalAttributes;
|
||||
use alloy_rpc_types_eth::erc4337::TransactionConditional;
|
||||
|
||||
/// Helper trait that allows attaching a [`TransactionConditional`].
|
||||
@ -10,6 +11,11 @@ pub trait MaybeConditionalTransaction {
|
||||
/// Get attached [`TransactionConditional`] if any.
|
||||
fn conditional(&self) -> Option<&TransactionConditional>;
|
||||
|
||||
/// Check if the conditional has exceeded the block attributes.
|
||||
fn has_exceeded_block_attributes(&self, block_attr: &BlockConditionalAttributes) -> bool {
|
||||
self.conditional().map(|tc| tc.has_exceeded_block_attributes(block_attr)).unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Helper that sets the conditional and returns the instance again
|
||||
fn with_conditional(mut self, conditional: TransactionConditional) -> Self
|
||||
where
|
||||
|
||||
@ -47,10 +47,8 @@ where
|
||||
};
|
||||
let mut to_remove = Vec::new();
|
||||
for tx in &pool.pooled_transactions() {
|
||||
if let Some(conditional) = tx.transaction.conditional() {
|
||||
if conditional.has_exceeded_block_attributes(&block_attr) {
|
||||
to_remove.push(*tx.hash());
|
||||
}
|
||||
if tx.transaction.has_exceeded_block_attributes(&block_attr) {
|
||||
to_remove.push(*tx.hash());
|
||||
}
|
||||
}
|
||||
let _ = pool.remove_transactions(to_remove);
|
||||
|
||||
Reference in New Issue
Block a user