Skip to content

Commit

Permalink
fix: edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Jul 20, 2021
1 parent 9c7c2e8 commit 87b46f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/burnchains/burnchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,14 +1185,19 @@ impl Burnchain {

// fetch all headers, no matter what
let mut end_block = indexer.sync_headers(sync_height, None)?;
if did_reorg {
if did_reorg && sync_height > 0 {
// a reorg happened, and the last header fetched
// is on a smaller fork than the one we just
// invalidated. Wait for more blocks.
while end_block < db_height {
if let Some(ref should_keep_running) = should_keep_running {
if !should_keep_running.load(Ordering::SeqCst) {
return Err(burnchain_error::CoordinatorClosed);
}
}
let end_height = target_block_height_opt.unwrap_or(0).max(db_height);
info!("Burnchain reorg happened at height {} invalidating chain tip {} but only {} headers presents on canonical chain. Retry in 1s", sync_height, db_height, end_block);
thread::sleep(Duration::from_millis(1000));
thread::sleep(Duration::from_millis(2000));
end_block = indexer.sync_headers(sync_height, Some(end_height))?;
}
}
Expand Down

0 comments on commit 87b46f8

Please sign in to comment.