upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sync/health.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-22 21:03:49 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-22 21:03:49 +0000
commit6b55efedba7c069eff7a3e335845a961d40274db (patch)
tree7e036869007cb503fda5a81d959ecd49a9b3e5a3 /src/sync/health.rs
parent1df90c609399c675e629b97294aee81a0b1e66dd (diff)
chore: cargo fmt and clippy
Diffstat (limited to 'src/sync/health.rs')
-rw-r--r--src/sync/health.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sync/health.rs b/src/sync/health.rs
index a10427f..2948707 100644
--- a/src/sync/health.rs
+++ b/src/sync/health.rs
@@ -136,12 +136,14 @@ impl RelayHealth {
136 136
137 // Check if we're in stability period after recovery 137 // Check if we're in stability period after recovery
138 // (recovered from failures but not yet proven stable) 138 // (recovered from failures but not yet proven stable)
139 if let (Some(last_success), Some(last_failure)) = (self.last_success_time, self.last_failure_time) { 139 if let (Some(last_success), Some(last_failure)) =
140 (self.last_success_time, self.last_failure_time)
141 {
140 // Only consider stability period if recovery happened after the last failure 142 // Only consider stability period if recovery happened after the last failure
141 if last_success > last_failure { 143 if last_success > last_failure {
142 let time_since_recovery = now.duration_since(last_success); 144 let time_since_recovery = now.duration_since(last_success);
143 let stability_period = Duration::from_secs(STABILITY_PERIOD_SECS); 145 let stability_period = Duration::from_secs(STABILITY_PERIOD_SECS);
144 146
145 if time_since_recovery < stability_period { 147 if time_since_recovery < stability_period {
146 // Still in stability period - remain degraded to prove stability 148 // Still in stability period - remain degraded to prove stability
147 return HealthState::Degraded; 149 return HealthState::Degraded;
@@ -339,9 +341,10 @@ impl RelayHealthTracker {
339 // Respect existing next_retry_at if it's later (e.g., from rate limiting) 341 // Respect existing next_retry_at if it's later (e.g., from rate limiting)
340 let new_retry_at = now + backoff; 342 let new_retry_at = now + backoff;
341 health.next_retry_at = Some( 343 health.next_retry_at = Some(
342 health.next_retry_at 344 health
345 .next_retry_at
343 .unwrap_or(new_retry_at) 346 .unwrap_or(new_retry_at)
344 .max(new_retry_at) 347 .max(new_retry_at),
345 ); 348 );
346 349
347 let new_state = health.state(); 350 let new_state = health.state();
@@ -393,7 +396,6 @@ impl RelayHealthTracker {
393 } 396 }
394 } 397 }
395 398
396
397 /// Check if relay is currently rate limited 399 /// Check if relay is currently rate limited
398 /// 400 ///
399 /// Returns true if the relay is in RateLimited state and the cooldown period 401 /// Returns true if the relay is in RateLimited state and the cooldown period