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

Commit

Permalink
Don't request old obsolete blocks (#4084)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar authored and gavofyork committed Nov 11, 2019
1 parent 223960f commit 5216fe1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/network/src/protocol/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,14 @@ impl<B: BlockT> ChainSync<B> {
peer.state = PeerSyncState::DownloadingStale(hash);
have_requests = true;
Some((id.clone(), req))
} else if let Some((range, req)) = peer_block_request(id, peer, blocks, attrs, max_parallel) {
} else if let Some((range, req)) = peer_block_request(
id,
peer,
blocks,
attrs,
max_parallel,
last_finalized
) {
peer.state = PeerSyncState::DownloadingNew(range.start);
trace!(
target: "sync",
Expand Down Expand Up @@ -1236,7 +1243,11 @@ fn peer_block_request<B: BlockT>(
blocks: &mut BlockCollection<B>,
attrs: &message::BlockAttributes,
max_parallel_downloads: u32,
finalized: NumberFor<B>,
) -> Option<(Range<NumberFor<B>>, BlockRequest<B>)> {
if peer.common_number < finalized {
return None;
}
if let Some(range) = blocks.needed_blocks(
id.clone(),
MAX_BLOCKS_TO_REQUEST,
Expand Down

0 comments on commit 5216fe1

Please sign in to comment.