Skip to content

Commit e6b1455

Browse files
committed
fix: from_min --> from_sec
ref: better comments
1 parent fc3c9bf commit e6b1455

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/robust_provider.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<N: Network, P: IntoProvider<N> + Send> IntoRobustProvider<N> for P {
126126
/// Default timeout used by `RobustProvider`
127127
pub const DEFAULT_MAX_TIMEOUT: Duration = Duration::from_secs(60);
128128
/// Default timeout for subscriptions (longer to accommodate slow block times)
129-
pub const DEFAULT_SUBSCRIPTION_TIMEOUT: Duration = Duration::from_mins(2);
129+
pub const DEFAULT_SUBSCRIPTION_TIMEOUT: Duration = Duration::from_secs(120);
130130
/// Default maximum number of retry attempts.
131131
pub const DEFAULT_MAX_RETRIES: usize = 3;
132132
/// Default base delay between retries.
@@ -143,7 +143,7 @@ pub struct RobustProviderBuilder<N: Network, P: IntoProvider<N>> {
143143
}
144144

145145
impl<N: Network, P: IntoProvider<N>> RobustProviderBuilder<N, P> {
146-
/// Create a new `RobustProvider` with default settings.
146+
/// Create a new [`RobustProvider`] with default settings.
147147
///
148148
/// The provided provider is treated as the primary provider.
149149
#[must_use]
@@ -158,7 +158,7 @@ impl<N: Network, P: IntoProvider<N>> RobustProviderBuilder<N, P> {
158158
}
159159
}
160160

161-
/// Create a new `RobustProvider` with no retry attempts and only timeout set.
161+
/// Create a new [`RobustProvider`] with no retry attempts and only timeout set.
162162
///
163163
/// The provided provider is treated as the primary provider.
164164
#[must_use]

src/robust_subscription.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use tracing::{error, info, warn};
1919

2020
use 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
2323
pub 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

Comments
 (0)