@@ -19,7 +19,7 @@ use tracing::{error, info, warn};
1919
2020use crate :: robust_provider:: { Error , RobustProvider } ;
2121
22- /// Default time interval between primary provider reconnection attempts (30 seconds)
22+ /// Default time interval between primary provider reconnection attempts
2323pub const DEFAULT_RECONNECT_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
2424
2525/// Maximum number of consecutive lags before switching providers
@@ -58,13 +58,13 @@ impl<N: Network> RobustSubscription<N> {
5858 /// - Attempt to receive from the current subscription
5959 /// - Handle errors by switching to fallback providers
6060 /// - Periodically attempt to reconnect to the primary provider
61+ /// - Will switch to fallback providers if [`subscription_timeout`] is exhausted
6162 ///
6263 /// # Errors
6364 ///
6465 /// Returns an error if all providers have been exhausted and failed.
6566 pub async fn recv ( & mut self ) -> Result < N :: HeaderResponse , Error > {
6667 loop {
67- // Check if we should attempt to reconnect to primary
6868 if self . should_reconnect_to_primary ( ) {
6969 info ! ( "Attempting to reconnect to primary provider" ) ;
7070 if let Err ( e) = self . try_reconnect_to_primary ( ) . await {
@@ -74,7 +74,6 @@ impl<N: Network> RobustSubscription<N> {
7474 }
7575 }
7676
77- // Try to receive from current subscription with timeout
7877 if let Some ( subscription) = & mut self . subscription {
7978 let subscription_timeout = self . robust_provider . subscription_timeout ;
8079 match timeout ( subscription_timeout, subscription. recv ( ) ) . await {
@@ -108,7 +107,6 @@ impl<N: Network> RobustSubscription<N> {
108107 } ,
109108 } ,
110109 Err ( e) => {
111- // Timeout occurred - no block received within subscription_timeout
112110 error ! (
113111 timeout_secs = subscription_timeout. as_secs( ) ,
114112 "Subscription timeout - no block received, switching provider"
@@ -125,7 +123,6 @@ impl<N: Network> RobustSubscription<N> {
125123
126124 fn should_reconnect_to_primary ( & self ) -> bool {
127125 // Only attempt reconnection if enough time has passed since last attempt
128- // The RobustProvider will try the primary provider first automatically
129126 match self . last_reconnect_attempt {
130127 None => false ,
131128 Some ( last_attempt) => last_attempt. elapsed ( ) >= self . reconnect_interval ,
0 commit comments