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: header downloading get stuck #4459

Merged
merged 2 commits into from
Jul 1, 2024
Merged
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
12 changes: 10 additions & 2 deletions src/chain_sync/tipset_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,21 @@ async fn sync_headers_in_reverse<DB: Blockstore + Sync + Send + 'static>(
continue;
}

let epoch_diff = oldest_pending_tipset.epoch() - current_head.epoch();
let window = min(epoch_diff, MAX_TIPSETS_TO_REQUEST as i64);
let window = min(
oldest_pending_tipset.epoch() - until_epoch, // (oldest_pending_tipset.epoch() - 1) - until_epoch + 1
MAX_TIPSETS_TO_REQUEST as i64,
);
let network_tipsets = network
.chain_exchange_headers(None, oldest_pending_tipset.parents(), window as u64)
.await
.map_err(TipsetRangeSyncerError::NetworkTipsetQueryFailed)?;

// Break when the until_epoch is a null epoch
if let Some(first) = network_tipsets.first() {
if first.epoch() < until_epoch {
break;
}
}
for tipset in network_tipsets
.into_iter()
.take_while(|ts| ts.epoch() >= until_epoch)
Expand Down
Loading