Skip to content

Commit ed256a3

Browse files
committed
reverted get_globally_accepted_block_count_in_tenure error generation
1 parent fa3eac9 commit ed256a3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

stacks-signer/src/signerdb.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -858,18 +858,12 @@ impl SignerDb {
858858
&self,
859859
tenure: &ConsensusHash,
860860
) -> Result<u64, DBError> {
861-
let query = "SELECT COALESCE((MAX(stacks_height) - MIN(stacks_height) + 1), 0), (SELECT COUNT(consensus_hash) FROM blocks WHERE consensus_hash = ?1) FROM blocks WHERE consensus_hash = ?1 AND state = ?2";
861+
let query = "SELECT COALESCE((MAX(stacks_height) - MIN(stacks_height) + 1), 0) as block_count FROM blocks WHERE consensus_hash = ?1 AND state = ?2";
862862
let args = params![tenure, &BlockState::GloballyAccepted.to_string()];
863-
let block_count_opt: Option<(u64, u64)> = query_row(&self.db, query, args)?;
863+
let block_count_opt: Option<u64> = query_row(&self.db, query, args)?;
864864
match block_count_opt {
865-
Some((block_count, tenure_count)) => {
866-
if tenure_count == 0 {
867-
Err(DBError::NotFoundError)
868-
} else {
869-
Ok(block_count)
870-
}
871-
}
872-
None => Err(DBError::NotFoundError),
865+
Some(block_count) => Ok(block_count),
866+
None => Ok(0),
873867
}
874868
}
875869

@@ -2076,11 +2070,11 @@ mod tests {
20762070

20772071
assert!(matches!(
20782072
db.get_globally_accepted_block_count_in_tenure(&consensus_hash_1)
2079-
.unwrap_err(),
2080-
DBError::NotFoundError
2073+
.unwrap(),
2074+
0
20812075
));
20822076

2083-
// locally accepted will return 0 (instead of DBError::NotFoundError) as the tenure is valid
2077+
// locally accepted still returns 0
20842078
block_info.signed_over = true;
20852079
block_info.state = BlockState::LocallyAccepted;
20862080
block_info.block.header.chain_length = 1;

0 commit comments

Comments
 (0)