You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: stacks-signer/src/signerdb.rs
+12-11Lines changed: 12 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -858,15 +858,15 @@ impl SignerDb {
858
858
&self,
859
859
tenure:&ConsensusHash,
860
860
) -> Result<u64,DBError>{
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";
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";
862
862
let args = params![tenure,&BlockState::GloballyAccepted.to_string()];
863
-
let block_count_opt:Option<u64> = query_row(&self.db, query, args)?;
863
+
let block_count_opt:Option<(u64,u64)> = query_row(&self.db, query, args)?;
864
864
match block_count_opt {
865
-
Some(block_count) => {
866
-
if block_count > 0{
867
-
Ok(block_count)
868
-
}else{
865
+
Some((block_count, tenure_count)) => {
866
+
if tenure_count == 0{
869
867
Err(DBError::NotFoundError)
868
+
}else{
869
+
Ok(block_count)
870
870
}
871
871
}
872
872
None => Err(DBError::NotFoundError),
@@ -2080,15 +2080,16 @@ mod tests {
2080
2080
DBError::NotFoundError
2081
2081
));
2082
2082
2083
+
// locally accepted will return 0 (instead of DBError::NotFoundError) as the tenure is valid
0 commit comments