Skip to content

Commit 5bedd6e

Browse files
committed
refactor: move checks early in broadcast
1 parent 1f79b52 commit 5bedd6e

File tree

1 file changed

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

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,6 @@ impl BlockMinerThread {
682682
reward_set: &RewardSet,
683683
stackerdbs: &StackerDBs,
684684
) -> Result<(), NakamotoNodeError> {
685-
let mut chain_state = neon_node::open_chainstate_with_faults(&self.config)
686-
.expect("FATAL: could not open chainstate DB");
687-
let sort_db = SortitionDB::open(
688-
&self.config.get_burn_db_file_path(),
689-
true,
690-
self.burnchain.pox_constants.clone(),
691-
)
692-
.expect("FATAL: could not open sortition DB");
693-
694685
if self.config.get_node_config(false).mock_mining {
695686
// If we're mock mining, we don't actually broadcast the block.
696687
return Ok(());
@@ -702,6 +693,15 @@ impl BlockMinerThread {
702693
));
703694
};
704695

696+
let mut chain_state = neon_node::open_chainstate_with_faults(&self.config)
697+
.expect("FATAL: could not open chainstate DB");
698+
let sort_db = SortitionDB::open(
699+
&self.config.get_burn_db_file_path(),
700+
true,
701+
self.burnchain.pox_constants.clone(),
702+
)
703+
.expect("FATAL: could not open sortition DB");
704+
705705
// push block via p2p block push
706706
self.broadcast_p2p(&sort_db, &mut chain_state, &block, reward_set)
707707
.map_err(NakamotoNodeError::AcceptFailure)?;

0 commit comments

Comments
 (0)