Skip to content

Commit

Permalink
Merge pull request #2780 from blockstack/fix/graceful-restart
Browse files Browse the repository at this point in the history
Only consider target_block_height when relevant
  • Loading branch information
lgalabru authored Jul 29, 2021
2 parents d18b0fb + 5a4a392 commit 53fb9fd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/burnchains/burnchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,16 +1209,25 @@ impl Burnchain {

debug!(
"Sync'ed headers from {} to {}. DB at {}",
start_block, end_block, db_height
sync_height, end_block, db_height
);

if let Some(target_block_height) = target_block_height_opt {
if target_block_height < end_block {
// `target_block_height` is used as a hint, but could also be completely off
// in certain situations. This function is directly reading the
// headers and syncing with the bitcoin-node, and the interval of blocks
// to download computed here should be considered as our source of truth.
if target_block_height > start_block && target_block_height < end_block {
debug!(
"Will download up to max burn block height {}",
target_block_height
);
end_block = target_block_height;
} else {
debug!(
"Ignoring target block height {} considered as irrelevant",
target_block_height
);
}
}

Expand Down

0 comments on commit 53fb9fd

Please sign in to comment.