Skip to content

Commit e65ad15

Browse files
committed
chore: move set_stacks_block_accepted later
Also, `commit` before announcing the block via the dispatcher.
1 parent 8a7768d commit e65ad15

File tree

1 file changed

+16
-16
lines changed
  • stackslib/src/chainstate/nakamoto

1 file changed

+16
-16
lines changed

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,14 +2001,6 @@ impl NakamotoChainState {
20012001
panic!()
20022002
});
20032003

2004-
// set stacks block accepted
2005-
let mut sort_tx = sort_db.tx_handle_begin(canonical_sortition_tip)?;
2006-
sort_tx.set_stacks_block_accepted(
2007-
&next_ready_block.header.consensus_hash,
2008-
&next_ready_block.header.block_hash(),
2009-
next_ready_block.header.chain_length,
2010-
)?;
2011-
20122004
// as a separate transaction, mark this block as processed.
20132005
// This is done separately so that the staging blocks DB, which receives writes
20142006
// from the network to store blocks, will be available for writes while a block is
@@ -2019,6 +2011,22 @@ impl NakamotoChainState {
20192011

20202012
let signer_bitvec = (&next_ready_block).header.pox_treatment.clone();
20212013

2014+
// set stacks block accepted
2015+
let mut sort_tx = sort_db.tx_handle_begin(canonical_sortition_tip)?;
2016+
sort_tx.set_stacks_block_accepted(
2017+
&next_ready_block.header.consensus_hash,
2018+
&next_ready_block.header.block_hash(),
2019+
next_ready_block.header.chain_length,
2020+
)?;
2021+
2022+
sort_tx
2023+
.commit()
2024+
.unwrap_or_else(|e| {
2025+
error!("Failed to commit sortition db transaction after committing chainstate and clarity block. The chainstate database is now corrupted.";
2026+
"error" => ?e);
2027+
panic!()
2028+
});
2029+
20222030
// announce the block, if we're connected to an event dispatcher
20232031
if let Some(dispatcher) = dispatcher_opt {
20242032
let block_event = (
@@ -2045,14 +2053,6 @@ impl NakamotoChainState {
20452053
);
20462054
}
20472055

2048-
sort_tx
2049-
.commit()
2050-
.unwrap_or_else(|e| {
2051-
error!("Failed to commit sortition db transaction after committing chainstate and clarity block. The chainstate database is now corrupted.";
2052-
"error" => ?e);
2053-
panic!()
2054-
});
2055-
20562056
Ok(Some(receipt))
20572057
}
20582058

0 commit comments

Comments
 (0)