Skip to content

Commit

Permalink
fix(raiko): refine error return
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft committed Sep 18, 2024
1 parent c2b0db5 commit eb57613
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 6 additions & 5 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ impl ProofActor {
}
result = Self::handle_message(proof_request, key.clone(), &opts, &chain_specs) => {
match result {
Ok(()) => {
info!("Host handling message");
Ok(status) => {
info!("Host handling message: {status:?}");
}
Err(error) => {
error!("Worker failed due to: {error:?}");
Expand Down Expand Up @@ -151,14 +151,14 @@ impl ProofActor {
key: TaskDescriptor,
opts: &Opts,
chain_specs: &SupportedChainSpecs,
) -> HostResult<()> {
) -> HostResult<TaskStatus> {
let mut manager = get_task_manager(&opts.clone().into());

let status = manager.get_task_proving_status(&key).await?;

if let Some(latest_status) = status.iter().last() {
if !matches!(latest_status.0, TaskStatus::Registered) {
return Ok(());
return Ok(latest_status.0);
}
}

Expand All @@ -178,7 +178,8 @@ impl ProofActor {
manager
.update_task_progress(key, status, proof.as_deref())
.await
.map_err(|e| e.into())
.map_err(|e| HostError::from(e))?;
Ok(status)
}
}

Expand Down
12 changes: 10 additions & 2 deletions host/src/server/api/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ impl From<Vec<u8>> for Status {

impl From<TaskStatus> for Status {
fn from(status: TaskStatus) -> Self {
Self::Ok {
data: ProofResponse::Status { status },
match status {
TaskStatus::Success
| TaskStatus::WorkInProgress
| TaskStatus::Registered => Self::Ok {
data: ProofResponse::Status { status },
},
_ => Self::Error {
error: "task_failed".to_string(),
message: format!("Task failed with status: {:?}", status),
},
}
}
}
Expand Down

0 comments on commit eb57613

Please sign in to comment.