Skip to content

Commit

Permalink
fix: dont exit if block marked as globally accepted/rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Nov 15, 2024
1 parent 91550e1 commit 76dea22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ impl BlockInfo {
self.state = state;
Ok(())
}

/// Check if the block is globally accepted or rejected
pub fn has_reached_consensus(&self) -> bool {
matches!(
self.state,
BlockState::GloballyAccepted | BlockState::GloballyRejected
)
}
}

/// This struct manages a SQLite database connection
Expand Down
13 changes: 9 additions & 4 deletions stacks-signer/src/v0/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,11 @@ impl Signer {
}
};
if let Err(e) = block_info.mark_locally_accepted(false) {
warn!("{self}: Failed to mark block as locally accepted: {e:?}",);
return None;
if !block_info.has_reached_consensus() {
warn!("{self}: Failed to mark block as locally accepted: {e:?}",);
return None;
}
block_info.signed_self.get_or_insert(get_epoch_time_secs());
}
let signature = self
.private_key
Expand Down Expand Up @@ -600,8 +603,10 @@ impl Signer {
}
};
if let Err(e) = block_info.mark_locally_rejected() {
warn!("{self}: Failed to mark block as locally rejected: {e:?}",);
return None;
if !block_info.has_reached_consensus() {
warn!("{self}: Failed to mark block as locally rejected: {e:?}",);
return None;
}
}
let block_rejection = BlockRejection::from_validate_rejection(
block_validate_reject.clone(),
Expand Down

0 comments on commit 76dea22

Please sign in to comment.