mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-29 04:05:21 +08:00
fix: make it so that when a node stops and restarts during bootstrap, it immediately begins to resume downloading stacks blocks (the current, erroneous behavior is for it to download 2100 bitcoin blocks unconditionally)
This commit is contained in:
@@ -316,15 +316,15 @@ impl RunLoop {
|
||||
coordinator_senders: CoordinatorChannels,
|
||||
) -> BitcoinRegtestController {
|
||||
// Initialize and start the burnchain.
|
||||
let mut burnchain = BitcoinRegtestController::with_burnchain(
|
||||
let mut burnchain_controller = BitcoinRegtestController::with_burnchain(
|
||||
self.config.clone(),
|
||||
Some(coordinator_senders),
|
||||
burnchain_opt,
|
||||
Some(self.should_keep_running.clone()),
|
||||
);
|
||||
|
||||
let burnchain_config = burnchain.get_burnchain();
|
||||
let epochs = burnchain.get_stacks_epochs();
|
||||
let burnchain_config = burnchain_controller.get_burnchain();
|
||||
let epochs = burnchain_controller.get_stacks_epochs();
|
||||
if !check_chainstate_db_versions(
|
||||
&epochs,
|
||||
&self.config.get_burn_db_file_path(),
|
||||
@@ -340,8 +340,25 @@ impl RunLoop {
|
||||
|
||||
info!("Start syncing Bitcoin headers, feel free to grab a cup of coffee, this can take a while");
|
||||
|
||||
let target_burnchain_block_height = 1.max(burnchain_config.first_block_height + 1);
|
||||
match burnchain.start(Some(target_burnchain_block_height)) {
|
||||
let target_burnchain_block_height = match burnchain_config
|
||||
.get_highest_burnchain_block()
|
||||
.expect("FATAL: failed to access burnchain database")
|
||||
{
|
||||
Some(burnchain_tip) => {
|
||||
// database exists already, and has blocks -- just sync to its tip.
|
||||
let target_height = burnchain_tip.block_height + 1;
|
||||
debug!("Burnchain DB exists and has blocks up to {}; synchronizing from where it left off up to {}", burnchain_tip.block_height, target_height);
|
||||
target_height
|
||||
}
|
||||
None => {
|
||||
// database does not exist yet
|
||||
let target_height = 1.max(burnchain_config.first_block_height + 1);
|
||||
debug!("Burnchain DB does not exist or does not have blocks; synchronizing to first burnchain block height {}", target_height);
|
||||
target_height
|
||||
}
|
||||
};
|
||||
|
||||
match burnchain_controller.start(Some(target_burnchain_block_height)) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
error!("Burnchain controller stopped: {}", e);
|
||||
@@ -350,14 +367,14 @@ impl RunLoop {
|
||||
};
|
||||
|
||||
// Invoke connect() to perform any db instantiation early
|
||||
if let Err(e) = burnchain.connect_dbs() {
|
||||
if let Err(e) = burnchain_controller.connect_dbs() {
|
||||
error!("Failed to connect to burnchain databases: {}", e);
|
||||
panic!();
|
||||
};
|
||||
|
||||
// TODO (hack) instantiate the sortdb in the burnchain
|
||||
let _ = burnchain.sortdb_mut();
|
||||
burnchain
|
||||
let _ = burnchain_controller.sortdb_mut();
|
||||
burnchain_controller
|
||||
}
|
||||
|
||||
/// Instantiate the Stacks chain state and start the chains coordinator thread.
|
||||
|
||||
Reference in New Issue
Block a user