fail if transaction submit has failed (#1584)

This commit is contained in:
Svyatoslav Nikolsky authored and Bastian Köcher committed 2024-04-10 10:28:37 +02:00
1 parent e534e90193
commit 0f79d1e86e
2 files changed
+11 -1

No files matched your search

@@ -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 {
+10
View File
@@ -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`.