File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use alloy::{
99 transports:: { RpcError , TransportErrorKind } ,
1010} ;
1111use backon:: { ExponentialBuilder , Retryable } ;
12+ use futures:: TryFutureExt ;
1213use thiserror:: Error ;
1314use tokio:: time:: { error as TokioError , timeout} ;
1415use tracing:: { error, info} ;
@@ -327,15 +328,11 @@ impl<N: Network> RobustProvider<N> {
327328 Fut : Future < Output = Result < T , RpcError < TransportErrorKind > > > ,
328329 {
329330 let primary = self . primary ( ) ;
330- let result = self . try_provider_with_timeout ( primary, & operation) . await ;
331-
332- if result. is_ok ( ) {
333- return result;
334- }
335-
336- let last_error = result. unwrap_err ( ) ;
337-
338- self . try_fallback_providers ( & operation, require_pubsub, last_error) . await
331+ self . try_provider_with_timeout ( primary, & operation)
332+ . or_else ( |last_error| {
333+ self . try_fallback_providers ( & operation, require_pubsub, last_error)
334+ } )
335+ . await
339336 }
340337
341338 pub ( crate ) async fn try_fallback_providers < T : Debug , F , Fut > (
You can’t perform that action at this time.
0 commit comments