mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
Don't request old obsolete blocks (#4084)
This commit is contained in:
committed by
Gavin Wood
parent
a62dcd5a13
commit
59ec4cb071
@@ -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",
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user