Skip to content

Commit

Permalink
Merge #1966
Browse files Browse the repository at this point in the history
1966: feat: enhanced locator r=quake,yangby-cryptape,keroro520 a=driftluo

After allowing ibd multi-node download, the premise of enabling multi-node download is to update the best-known header of the corresponding node as soon as possible.

However, as the chain height continues to increase, the exponentially descending abstraction header of the locator will cause the minimum height header in the locator to become higher and higher, that is, it will take longer and longer to enable ibd multi-node download.

So, slightly improve the step insertion method of the locator so that the minimum height within it is as low as possible

Co-authored-by: driftluo <driftluo@foxmail.com>
  • Loading branch information
bors[bot] and driftluo committed Mar 20, 2020
2 parents 61c79c3 + 6895343 commit bb36093
Showing 1 changed file with 10 additions and 0 deletions.
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 @@ -1152,6 +1154,14 @@ impl ActiveChain {
}

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.shared.consensus().genesis_hash());
Expand Down

0 comments on commit bb36093

Please sign in to comment.