Skip to content

Commit

Permalink
Remove unnecessary range checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jan 27, 2025
1 parent d72b61d commit b0774e0
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions beacon_node/network/src/sync/range_sync/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,36 +277,6 @@ impl<E: EthSpec, B: BatchConfig> BatchInfo<E, B> {
> {
match self.state.poison() {
BatchState::Downloading(peer, _request_id) => {
// verify that blocks are in range
if let Some(last_slot) = blocks.last().map(|b| b.slot()) {
// the batch is non-empty
let first_slot = blocks[0].slot();

let failed_range = if first_slot < self.start_slot {
Some((self.start_slot, first_slot))
} else if self.end_slot < last_slot {
Some((self.end_slot, last_slot))
} else {
None
};

if let Some((expected, received)) = failed_range {
// this is a failed download, register the attempt and check if the batch
// can be tried again
self.failed_download_attempts.push(peer);
self.state = if self.failed_download_attempts.len()
>= B::max_batch_download_attempts() as usize
{
BatchState::Failed
} else {
// drop the blocks
BatchState::AwaitingDownload
};

return Err(Ok((expected, received, self.outcome())));
}
}

let received = blocks.len();
self.state = BatchState::AwaitingProcessing(peer, blocks, Instant::now());
Ok(received)
Expand Down

0 comments on commit b0774e0

Please sign in to comment.