Skip to content

Commit

Permalink
fail if transaction submit has failed (paritytech#1584)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 614adde commit b940914
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bridges/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 bridges/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 b940914

Please sign in to comment.