Skip to content

Commit ebbcf60

Browse files
committed
feat: move SortitionDB::open closer to its use
Also change it to not require write access.
1 parent c6f3471 commit ebbcf60

File tree

1 file changed

+10
-9
lines changed
  • testnet/stacks-node/src/nakamoto_node

1 file changed

+10
-9
lines changed

testnet/stacks-node/src/nakamoto_node/miner.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -660,15 +660,6 @@ impl BlockMinerThread {
660660
self.mined_blocks += 1;
661661
}
662662

663-
let Ok(sort_db) = SortitionDB::open(
664-
&self.config.get_burn_db_file_path(),
665-
true,
666-
self.burnchain.pox_constants.clone(),
667-
) else {
668-
error!("Failed to open sortition DB. Will try mining again.");
669-
return Ok(());
670-
};
671-
672663
if let Some(last_block_mined) = &self.last_block_mined {
673664
// Wait until the last block mined has been processed
674665
loop {
@@ -685,6 +676,16 @@ impl BlockMinerThread {
685676
}
686677

687678
thread::sleep(Duration::from_millis(ABORT_TRY_AGAIN_MS));
679+
680+
// Check if the burnchain tip has changed
681+
let Ok(sort_db) = SortitionDB::open(
682+
&self.config.get_burn_db_file_path(),
683+
false,
684+
self.burnchain.pox_constants.clone(),
685+
) else {
686+
error!("Failed to open sortition DB. Will try mining again.");
687+
return Ok(());
688+
};
688689
if self.check_burn_tip_changed(&sort_db).is_err() {
689690
return Err(NakamotoNodeError::BurnchainTipChanged);
690691
}

0 commit comments

Comments
 (0)