Skip to content

Commit

Permalink
get_tenure_raw error message upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJOHN974 committed Jan 6, 2025
1 parent 9f393d8 commit cf199b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions signer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ pub enum Error {
#[error("observed a tenure identified by a StacksBlockId with with no blocks")]
EmptyStacksTenure,

/// This should never happen
#[error("get_tenure_raw returned unexpected responce: {0}. Expected: {1}")]
GetTenureRawMismatch(StacksBlockId, StacksBlockId),

/// Received an error in call to estimatesmartfee RPC call
#[error("failed to get fee estimate from bitcoin-core for target {1}. {0}")]
EstimateSmartFee(#[source] bitcoincore_rpc::Error, u16),
Expand Down
10 changes: 9 additions & 1 deletion signer/src/stacks/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,15 @@ impl StacksClient {
// The first block in the GET /v3/tenures/<block-id> response
// is always the block related to the given <block-id>. But we
// already have that block, so we can skip adding it again.
debug_assert_eq!(blocks.first().map(|b| b.block_id()), Some(last_block_id));

if let Some(received_id) = blocks.first().map(|b| b.block_id()) {
if received_id != last_block_id {
return Err(Error::GetTenureRawMismatch(received_id, last_block_id));
}
} else {
return Err(Error::EmptyStacksTenure);
}

tenure_blocks.extend(blocks.into_iter().skip(1))
}

Expand Down

0 comments on commit cf199b4

Please sign in to comment.