Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix additional edge cases in fast sync process #5663

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions substrate/client/network/sync/src/strategy/chain_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Metrics {
}
}

#[derive(Debug, Clone)]
enum AllowedRequests {
Some(HashSet<PeerId>),
All,
Expand Down Expand Up @@ -1560,13 +1561,14 @@ where
let best_queued = self.best_queued_number;
let client = &self.client;
let queue_blocks = &self.queue_blocks;
let allowed_requests = self.allowed_requests.take();
let allowed_requests = self.allowed_requests.clone();
let max_parallel = if is_major_syncing { 1 } else { self.max_parallel_downloads };
let max_blocks_per_request = self.max_blocks_per_request;
let gap_sync = &mut self.gap_sync;
let disconnected_peers = &mut self.disconnected_peers;
let metrics = self.metrics.as_ref();
self.peers
let requests = self
.peers
.iter_mut()
.filter_map(move |(&id, peer)| {
if !peer.state.is_available() ||
Expand Down Expand Up @@ -1665,7 +1667,13 @@ where
None
}
})
.collect()
.collect::<Vec<_>>();

if !requests.is_empty() {
liuchengxu marked this conversation as resolved.
Show resolved Hide resolved
self.allowed_requests.take();
}

requests
}

/// Get a state request scheduled by sync to be sent out (if any).
Expand Down