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

feat: enhanced locator #1966

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions sync/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const GET_HEADERS_TIMEOUT: Duration = Duration::from_secs(15);
const TX_FILTER_SIZE: usize = 50000;
const TX_ASKED_SIZE: usize = TX_FILTER_SIZE;
const ORPHAN_BLOCK_SIZE: usize = 1024;
// 2 ** 13 < 6 * 1800 < 2 ** 14
const ONE_DAY_BLOCK_NUMBER: u64 = 8192;

// State used to enforce CHAIN_SYNC_TIMEOUT
// Only in effect for connections that are outbound, non-manual,
Expand Down Expand Up @@ -983,6 +985,14 @@ impl SyncSnapshot {
}

if index < step {
// Insert some low-height blocks in the locator
// to quickly start parallel ibd block downloads
// and it should not be too much
if locator.len() < 31 && index > ONE_DAY_BLOCK_NUMBER {
index >>= 1;
base = header_hash;
continue;
}
// always include genesis hash
if index != 0 {
locator.push(self.consensus().genesis_hash());
Expand Down