Skip to content

Commit

Permalink
refactor(host): make proof handler more ergonomic
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Jul 12, 2024
1 parent 7d022bf commit 5f35417
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,17 @@ impl ProofActor {
.update_task_progress(key.clone(), TaskStatus::WorkInProgress, None)
.await?;

match handle_proof(&proof_request, opts, chain_specs).await {
let (status, proof) = match handle_proof(&proof_request, opts, chain_specs).await {
Err(error) => (error.into(), None),
Ok(ProofResponse { proof, .. }) => {
let proof_string = proof.unwrap_or_default();
let proof = proof_string.as_bytes();

manager
.update_task_progress(key.clone(), TaskStatus::Success, Some(proof))
.await?;
Ok(())
}
Err(error) => {
manager
.update_task_progress(key, (&error).into(), None)
.await?;
Err(error)
(TaskStatus::Success, proof.map(|string| string.into_bytes()))
}
}
};

manager
.update_task_progress(key, status, proof.as_deref())
.await
.map_err(|e| e.into())
}
}

Expand Down

0 comments on commit 5f35417

Please sign in to comment.