Skip to content

Commit 7937616

Browse files
committed
ref: revert try_operation_with_failover ref
1 parent e441e2e commit 7937616

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/robust_provider/provider.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use alloy::{
99
transports::{RpcError, TransportErrorKind},
1010
};
1111
use backon::{ExponentialBuilder, Retryable};
12-
use futures::TryFutureExt;
1312
use thiserror::Error;
1413
use tokio::time::{error as TokioError, timeout};
1514
use tracing::{error, info};
@@ -353,11 +352,15 @@ impl<N: Network> RobustProvider<N> {
353352
Fut: Future<Output = Result<T, RpcError<TransportErrorKind>>>,
354353
{
355354
let primary = self.primary();
356-
self.try_provider_with_timeout(primary, &operation)
357-
.or_else(|last_error| {
358-
self.try_fallback_providers(&operation, require_pubsub, last_error)
359-
})
360-
.await
355+
let result = self.try_provider_with_timeout(primary, &operation).await;
356+
357+
if result.is_ok() {
358+
return result;
359+
}
360+
361+
let last_error = result.unwrap_err();
362+
363+
self.try_fallback_providers(&operation, require_pubsub, last_error).await
361364
}
362365

363366
pub(crate) async fn try_fallback_providers<T: Debug, F, Fut>(

0 commit comments

Comments
 (0)