mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 16:53:21 +08:00
logs: signer block responses to info. display formatting for block response
This commit is contained in:
@@ -823,6 +823,27 @@ pub enum BlockResponse {
|
||||
Rejected(BlockRejection),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for BlockResponse {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
BlockResponse::Accepted(a) => {
|
||||
write!(
|
||||
f,
|
||||
"BlockAccepted: signer_sighash = {}, signature = {}",
|
||||
a.0, a.1
|
||||
)
|
||||
}
|
||||
BlockResponse::Rejected(r) => {
|
||||
write!(
|
||||
f,
|
||||
"BlockRejected: signer_sighash = {}, code = {}, reason = {}",
|
||||
r.reason_code, r.reason, r.signer_signature_hash
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockResponse {
|
||||
/// Create a new accepted BlockResponse for the provided block signer signature hash and signature
|
||||
pub fn accepted(hash: Sha512Trunc256Sum, sig: Signature) -> Self {
|
||||
|
||||
@@ -989,15 +989,18 @@ impl Signer {
|
||||
|
||||
let block_submission = if block_vote.rejected {
|
||||
// We signed a rejection message. Return a rejection message
|
||||
BlockResponse::rejected(block_vote.signer_signature_hash, signature.clone()).into()
|
||||
BlockResponse::rejected(block_vote.signer_signature_hash, signature.clone())
|
||||
} else {
|
||||
// we agreed to sign the block hash. Return an approval message
|
||||
BlockResponse::accepted(block_vote.signer_signature_hash, signature.clone()).into()
|
||||
BlockResponse::accepted(block_vote.signer_signature_hash, signature.clone())
|
||||
};
|
||||
|
||||
// Submit signature result to miners to observe
|
||||
debug!("{self}: submit block response {block_submission:?}");
|
||||
if let Err(e) = self.stackerdb.send_message_with_retry(block_submission) {
|
||||
info!("{self}: Submit block response: {block_submission}");
|
||||
if let Err(e) = self
|
||||
.stackerdb
|
||||
.send_message_with_retry(block_submission.into())
|
||||
{
|
||||
warn!("{self}: Failed to send block submission to stacker-db: {e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,6 +693,12 @@ impl FromSql for ThresholdSignature {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ThresholdSignature {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
to_hex(&self.serialize_to_vec()).fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSql for ThresholdSignature {
|
||||
fn to_sql(&self) -> rusqlite::Result<ToSqlOutput> {
|
||||
let bytes = self.serialize_to_vec();
|
||||
|
||||
Reference in New Issue
Block a user