Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fail if transaction submit has failed (#1584)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored Sep 26, 2022
1 parent a64b8dd commit e0feb85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion relays/messages/src/message_race_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ pub async fn run<P: MessageRace, SC: SourceClient<P>, TC: TargetClient<P>>(
&mut target_go_offline_future,
async_std::task::sleep,
|| format!("Error submitting proof {}", P::target_name()),
).fail_if_connection_error(FailedClient::Target)?;
).fail_if_error(FailedClient::Target).map(|_| true)?;
},
target_transaction_status = target_tx_tracker => {
if target_transaction_status == TrackedTransactionStatus::Lost {
Expand Down
10 changes: 10 additions & 0 deletions relays/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ impl ProcessFutureResult {
}
}

/// Returns `Ok(())` if future has succeeded.
/// Returns `Err(failed_client)` otherwise.
pub fn fail_if_error(self, failed_client: FailedClient) -> Result<(), FailedClient> {
if self.is_ok() {
Ok(())
} else {
Err(failed_client)
}
}

/// Returns Ok(true) if future has succeeded.
/// Returns Ok(false) if future has failed with non-connection error.
/// Returns Err if future is `ConnectionFailed`.
Expand Down

0 comments on commit e0feb85

Please sign in to comment.