Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Jun 24, 2024
1 parent dff9f29 commit 5880cbf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions zero_bin/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ where
let chain_id = provider.get_chain_id().await?;

let previous_block_numbers =
std::iter::successors(Some(target_block_number as i128), |&it| it.checked_sub(1))
.skip(1)
.take(PREVIOUS_HASHES_SIZE)
.filter(|i| *i >= 0)
.collect::<Vec<_>>();
std::iter::successors(Some(target_block_number as i128 - 1), |&it| {
it.checked_sub(1)
})
.take(PREVIOUS_HASHES_SIZE)
.filter(|i| *i >= 0)
.collect::<Vec<_>>();
let concurrency = previous_block_numbers.len();
let collected_hashes = futures::stream::iter(
previous_block_numbers
Expand Down Expand Up @@ -129,7 +130,7 @@ where
collected_hashes
.into_iter()
.flatten()
.filter(|(_, block_num)| block_num.is_some_and(|v| v as u64 != target_block_number))
.filter(|(_, block_num)| block_num.is_some())
.for_each(|(hash, block_num)| {
if let (Some(hash), Some(block_num)) = (hash, block_num) {
// Most recent previous block hash is expected at the end of the array
Expand Down

0 comments on commit 5880cbf

Please sign in to comment.