Skip to content

Commit 949088f

Browse files
committed
when marking block as global accepted/rejected, remove pending validation
1 parent 5f8f9eb commit 949088f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

stacks-signer/src/chainstate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ impl SortitionsView {
589589
signer_db.block_lookup(&nakamoto_tip.signer_signature_hash())
590590
{
591591
if block_info.state != BlockState::GloballyAccepted {
592-
if let Err(e) = block_info.mark_globally_accepted() {
593-
warn!("Failed to update block info in db: {e}");
592+
if let Err(e) = signer_db.mark_block_globally_accepted(&mut block_info) {
593+
warn!("Failed to mark block as globally accepted: {e}");
594594
} else if let Err(e) = signer_db.insert_block(&block_info) {
595595
warn!("Failed to update block info in db: {e}");
596596
}

stacks-signer/src/signerdb.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl BlockInfo {
211211

212212
/// Mark this block as valid, signed over, and records a group timestamp in the block info if it wasn't
213213
/// already set.
214-
pub fn mark_globally_accepted(&mut self) -> Result<(), String> {
214+
fn mark_globally_accepted(&mut self) -> Result<(), String> {
215215
self.move_to(BlockState::GloballyAccepted)?;
216216
self.valid = Some(true);
217217
self.signed_over = true;
@@ -227,7 +227,7 @@ impl BlockInfo {
227227
}
228228

229229
/// Mark the block as globally rejected and invalid
230-
pub fn mark_globally_rejected(&mut self) -> Result<(), String> {
230+
fn mark_globally_rejected(&mut self) -> Result<(), String> {
231231
self.move_to(BlockState::GloballyRejected)?;
232232
self.valid = Some(false);
233233
Ok(())
@@ -1134,6 +1134,24 @@ impl SignerDb {
11341134
);
11351135
tenure_extend_timestamp
11361136
}
1137+
1138+
/// Mark a block as globally accepted
1139+
pub fn mark_block_globally_accepted(&self, block_info: &mut BlockInfo) -> Result<(), DBError> {
1140+
block_info
1141+
.mark_globally_accepted()
1142+
.map_err(DBError::Other)?;
1143+
self.remove_pending_block_validation(&block_info.signer_signature_hash())?;
1144+
Ok(())
1145+
}
1146+
1147+
/// Mark a block as globally rejected
1148+
pub fn mark_block_globally_rejected(&self, block_info: &mut BlockInfo) -> Result<(), DBError> {
1149+
block_info
1150+
.mark_globally_rejected()
1151+
.map_err(DBError::Other)?;
1152+
self.remove_pending_block_validation(&block_info.signer_signature_hash())?;
1153+
Ok(())
1154+
}
11371155
}
11381156

11391157
fn try_deserialize<T>(s: Option<String>) -> Result<Option<T>, DBError>

stacks-signer/src/v0/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ impl Signer {
922922
return;
923923
}
924924
debug!("{self}: {total_reject_weight}/{total_weight} signers voteed to reject the block {block_hash}");
925-
if let Err(e) = block_info.mark_globally_rejected() {
925+
if let Err(e) = self.signer_db.mark_block_globally_rejected(&mut block_info) {
926926
warn!("{self}: Failed to mark block as globally rejected: {e:?}",);
927927
}
928928
if let Err(e) = self.signer_db.insert_block(&block_info) {

0 commit comments

Comments
 (0)