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

Increase parallel downloads to 5 #4045

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
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: 10 additions & 4 deletions core/network/src/protocol/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,17 @@ impl<B: BlockT> ChainSync<B> {
Some((id.clone(), req))
} else if let Some((range, req)) = peer_block_request(id, peer, blocks, attrs, major_sync) {
peer.state = PeerSyncState::DownloadingNew(range.start);
trace!(target: "sync", "New block request for {}", id);
trace!(
target: "sync",
"New block request for {}, (best:{}, common:{}) {:?}",
id,
peer.best_number,
peer.common_number,
req,
);
have_requests = true;
Some((id.clone(), req))
} else {
trace!(target: "sync", "No new block request for {}", id);
None
}
});
Expand Down Expand Up @@ -1006,7 +1012,7 @@ impl<B: BlockT> ChainSync<B> {
{
let header = &announce.header;
let number = *header.number();
debug!(target: "sync", "Received block announcement with number {:?}", number);
debug!(target: "sync", "Received block announcement {:?} with number {:?} from {}", hash, number, who);
if number.is_zero() {
warn!(target: "sync", "Ignored genesis block (#0) announcement from {}: {}", who, hash);
return OnBlockAnnounce::Nothing
Expand Down Expand Up @@ -1228,7 +1234,7 @@ fn peer_block_request<B: BlockT>(
attrs: &message::BlockAttributes,
major_sync: bool,
) -> Option<(Range<NumberFor<B>>, BlockRequest<B>)> {
let max_parallel = if major_sync { 1 } else { 3 };
let max_parallel = if major_sync { 1 } else { 5 };
arkpar marked this conversation as resolved.
Show resolved Hide resolved
if let Some(range) = blocks.needed_blocks(
id.clone(),
MAX_BLOCKS_TO_REQUEST,
Expand Down
4 changes: 4 additions & 0 deletions core/network/src/protocol/sync/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ impl<B: BlockT> BlockCollection<B> {
max_parallel: u32,
) -> Option<Range<NumberFor<B>>>
{
if peer_best <= common {
// Bail out early
return None;
}
// First block number that we need to download
let first_different = common + <NumberFor<B>>::one();
let count = (count as u32).into();
Expand Down