Skip to content

Commit

Permalink
refactor: pass only signed_entity_type to `transition_from_ready_to…
Browse files Browse the repository at this point in the history
…_sign_to_ready_to_sign`and not the certificate
  • Loading branch information
sfauvel committed Sep 16, 2024
1 parent e6d4f9e commit ffe73cc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mithril-signer/src/runtime/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ impl StateMachine {
.await
{
*state = self
.transition_from_ready_to_sign_to_ready_to_sign(*epoch, &certificate)
.transition_from_ready_to_sign_to_ready_to_sign(
*epoch,
&certificate.signed_entity_type,
)
.await?;
}
}
Expand Down Expand Up @@ -412,10 +415,9 @@ impl StateMachine {
/// Launch the transition process from the `ReadyToSign` to the `ReadyToSign` state.
async fn transition_from_ready_to_sign_to_ready_to_sign(
&self,
state_epoch: Epoch,
pending_certificate: &CertificatePending,
current_epoch: Epoch,
signed_entity_type: &SignedEntityType,
) -> Result<SignerState, RuntimeError> {
let current_epoch = pending_certificate.epoch;
let (retrieval_epoch, next_retrieval_epoch) = (
current_epoch.offset_to_signer_retrieval_epoch()?,
current_epoch.offset_to_next_signer_retrieval_epoch(),
Expand All @@ -433,7 +435,7 @@ impl StateMachine {

let message = self
.runner
.compute_message(&pending_certificate.signed_entity_type)
.compute_message(signed_entity_type)
.await
.map_err(|e| RuntimeError::KeepState {
message: format!("Could not compute message during 'ready to sign → ready to sign' phase (current epoch {current_epoch:?})"),
Expand All @@ -448,7 +450,7 @@ impl StateMachine {
message: format!("Could not compute single signature during 'ready to sign → ready to sign' phase (current epoch {current_epoch:?})"),
nested_error: Some(e)
})?;
self.runner.send_single_signature(&pending_certificate.signed_entity_type, single_signatures).await
self.runner.send_single_signature(signed_entity_type, single_signatures).await
.map_err(|e| RuntimeError::KeepState {
message: format!("Could not send single signature during 'ready to sign → ready to sign' phase (current epoch {current_epoch:?})"),
nested_error: Some(e)
Expand All @@ -460,8 +462,8 @@ impl StateMachine {
.signature_registration_success_last_epoch_gauge_set(current_epoch);

Ok(SignerState::ReadyToSign {
epoch: state_epoch,
last_signed_entity_type: Some(pending_certificate.to_owned().signed_entity_type),
epoch: current_epoch,
last_signed_entity_type: Some(signed_entity_type.to_owned()),
})
}

Expand Down

0 comments on commit ffe73cc

Please sign in to comment.