mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
chore(downloader): simplify the canonical blocks check (#22739)
Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ use alloy_eips::BlockHashOrNumber;
|
||||
use alloy_primitives::{BlockHash, BlockNumber, Sealable, B256};
|
||||
use async_compression::tokio::bufread::GzipDecoder;
|
||||
use futures::Future;
|
||||
use itertools::Either;
|
||||
use itertools::{Either, Itertools};
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_network_p2p::{
|
||||
bodies::client::{BodiesClient, BodiesFut},
|
||||
@@ -163,17 +163,9 @@ impl<B: FullBlock> FileClient<B> {
|
||||
if self.headers.is_empty() {
|
||||
return true
|
||||
}
|
||||
let mut nums = self.headers.keys().copied().collect::<Vec<_>>();
|
||||
nums.sort_unstable();
|
||||
let mut iter = nums.into_iter();
|
||||
let mut lowest = iter.next().expect("not empty");
|
||||
for next in iter {
|
||||
if next != lowest + 1 {
|
||||
return false
|
||||
}
|
||||
lowest = next;
|
||||
}
|
||||
true
|
||||
let (min, max) = self.headers.keys().minmax().into_option().expect("not empty");
|
||||
// Contiguous range from min to max means no gaps
|
||||
*max - *min + 1 == self.headers.len() as u64
|
||||
}
|
||||
|
||||
/// Use the provided bodies as the file client's block body buffer.
|
||||
|
||||
Reference in New Issue
Block a user