Skip to content

Commit

Permalink
fix(rpc): less clones in logs filter
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Mar 8, 2024
1 parent 3c028e5 commit 575b256
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/rpc/rpc/src/eth/logs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ pub(crate) fn log_matches_filter(
log: &reth_primitives::Log,
params: &FilteredParams,
) -> bool {
if params.filter.is_some() &&
(!params.filter_block_range(block.number) ||
!params.filter_block_hash(block.hash) ||
!params.filter_address(&from_primitive_log(log.clone())) ||
!params.filter_topics(&from_primitive_log(log.clone())))
{
return false
if params.filter.is_none() {
return true
}
true

if params.filter_block_range(block.number) && params.filter_block_hash(block.hash) {
let log = from_primitive_log(log.clone());
if params.filter_address(&log) && params.filter_topics(&log) {
return true
}
}

false
}

/// Computes the block range based on the filter range and current block numbers
Expand Down

0 comments on commit 575b256

Please sign in to comment.