Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 5216fe1

Browse files
arkpargavofyork
authored andcommitted
Don't request old obsolete blocks (#4084)
1 parent 223960f commit 5216fe1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

core/network/src/protocol/sync.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,14 @@ impl<B: BlockT> ChainSync<B> {
597597
peer.state = PeerSyncState::DownloadingStale(hash);
598598
have_requests = true;
599599
Some((id.clone(), req))
600-
} else if let Some((range, req)) = peer_block_request(id, peer, blocks, attrs, max_parallel) {
600+
} else if let Some((range, req)) = peer_block_request(
601+
id,
602+
peer,
603+
blocks,
604+
attrs,
605+
max_parallel,
606+
last_finalized
607+
) {
601608
peer.state = PeerSyncState::DownloadingNew(range.start);
602609
trace!(
603610
target: "sync",
@@ -1236,7 +1243,11 @@ fn peer_block_request<B: BlockT>(
12361243
blocks: &mut BlockCollection<B>,
12371244
attrs: &message::BlockAttributes,
12381245
max_parallel_downloads: u32,
1246+
finalized: NumberFor<B>,
12391247
) -> Option<(Range<NumberFor<B>>, BlockRequest<B>)> {
1248+
if peer.common_number < finalized {
1249+
return None;
1250+
}
12401251
if let Some(range) = blocks.needed_blocks(
12411252
id.clone(),
12421253
MAX_BLOCKS_TO_REQUEST,

0 commit comments

Comments
 (0)