Skip to content

Commit 0dc1524

Browse files
committed
fix: move logic for removing/retrying pending block responses
1 parent 014f44b commit 0dc1524

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -557,33 +557,6 @@ impl Signer {
557557
self.handle_block_rejection(block_rejection);
558558
}
559559
};
560-
561-
// Remove this block validation from the pending table
562-
let signer_sig_hash = block_response.signer_signature_hash();
563-
self.signer_db
564-
.remove_pending_block_validation(&signer_sig_hash)
565-
.unwrap_or_else(|e| warn!("{self}: Failed to remove pending block validation: {e:?}"));
566-
567-
// Check if there is a pending block validation that we need to submit to the node
568-
match self.signer_db.get_pending_block_validation() {
569-
Ok(Some(signer_sig_hash)) => {
570-
info!("{self}: Found a pending block validation: {signer_sig_hash:?}");
571-
match self.signer_db.block_lookup(&signer_sig_hash) {
572-
Ok(Some(block_info)) => {
573-
self.submit_block_for_validation(stacks_client, &block_info.block);
574-
}
575-
Ok(None) => {
576-
// This should never happen
577-
error!(
578-
"{self}: Pending block validation not found in DB: {signer_sig_hash:?}"
579-
);
580-
}
581-
Err(e) => error!("{self}: Failed to get block info: {e:?}"),
582-
}
583-
}
584-
Ok(None) => {}
585-
Err(e) => warn!("{self}: Failed to get pending block validation: {e:?}"),
586-
}
587560
}
588561

589562
/// Handle the block validate ok response. Returns our block response if we have one
@@ -726,6 +699,12 @@ impl Signer {
726699
self.handle_block_validate_reject(block_validate_reject)
727700
}
728701
};
702+
// Remove this block validation from the pending table
703+
let signer_sig_hash = block_validate_response.signer_signature_hash();
704+
self.signer_db
705+
.remove_pending_block_validation(&signer_sig_hash)
706+
.unwrap_or_else(|e| warn!("{self}: Failed to remove pending block validation: {e:?}"));
707+
729708
let Some(response) = block_response else {
730709
return;
731710
};
@@ -745,6 +724,27 @@ impl Signer {
745724
warn!("{self}: Failed to send block rejection to stacker-db: {e:?}",);
746725
}
747726
}
727+
728+
// Check if there is a pending block validation that we need to submit to the node
729+
match self.signer_db.get_pending_block_validation() {
730+
Ok(Some(signer_sig_hash)) => {
731+
info!("{self}: Found a pending block validation: {signer_sig_hash:?}");
732+
match self.signer_db.block_lookup(&signer_sig_hash) {
733+
Ok(Some(block_info)) => {
734+
self.submit_block_for_validation(stacks_client, &block_info.block);
735+
}
736+
Ok(None) => {
737+
// This should never happen
738+
error!(
739+
"{self}: Pending block validation not found in DB: {signer_sig_hash:?}"
740+
);
741+
}
742+
Err(e) => error!("{self}: Failed to get block info: {e:?}"),
743+
}
744+
}
745+
Ok(None) => {}
746+
Err(e) => warn!("{self}: Failed to get pending block validation: {e:?}"),
747+
}
748748
}
749749

750750
/// Check the current tracked submitted block proposal to see if it has timed out.

0 commit comments

Comments
 (0)