From 6b55efedba7c069eff7a3e335845a961d40274db Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 22 Dec 2025 21:03:49 +0000 Subject: chore: cargo fmt and clippy --- src/sync/health.rs | 12 +++++++----- src/sync/mod.rs | 2 +- src/sync/relay_connection.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/sync') 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 { // Check if we're in stability period after recovery // (recovered from failures but not yet proven stable) - if let (Some(last_success), Some(last_failure)) = (self.last_success_time, self.last_failure_time) { + if let (Some(last_success), Some(last_failure)) = + (self.last_success_time, self.last_failure_time) + { // Only consider stability period if recovery happened after the last failure if last_success > last_failure { let time_since_recovery = now.duration_since(last_success); let stability_period = Duration::from_secs(STABILITY_PERIOD_SECS); - + if time_since_recovery < stability_period { // Still in stability period - remain degraded to prove stability return HealthState::Degraded; @@ -339,9 +341,10 @@ impl RelayHealthTracker { // Respect existing next_retry_at if it's later (e.g., from rate limiting) let new_retry_at = now + backoff; health.next_retry_at = Some( - health.next_retry_at + health + .next_retry_at .unwrap_or(new_retry_at) - .max(new_retry_at) + .max(new_retry_at), ); let new_state = health.state(); @@ -393,7 +396,6 @@ impl RelayHealthTracker { } } - /// Check if relay is currently rate limited /// /// Returns true if the relay is in RateLimited state and the cooldown period diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 6ec39e8..65affc6 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -1599,7 +1599,7 @@ impl SyncManager { write_policy: &Nip34WritePolicy, local_relay: &LocalRelay, ) -> ProcessResult { - use nostr_relay_builder::prelude::{WritePolicyResult, WritePolicy}; + use nostr_relay_builder::prelude::{WritePolicy, WritePolicyResult}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; // Check if event already exists match database.event_by_id(&event.id).await { diff --git a/src/sync/relay_connection.rs b/src/sync/relay_connection.rs index de20e0f..bd9ab80 100644 --- a/src/sync/relay_connection.rs +++ b/src/sync/relay_connection.rs @@ -24,7 +24,7 @@ use crate::nostr::builder::SharedDatabase; #[derive(Debug)] pub enum RelayEvent { /// A new event was received (event, subscription_id) - Event(Event, SubscriptionId), + Event(Box, SubscriptionId), /// End of stored events for a subscription EndOfStoredEvents(SubscriptionId), /// NOTICE message from relay @@ -219,7 +219,7 @@ impl RelayConnection { "Received event" ); if event_sender - .send(RelayEvent::Event(*event, subscription_id.clone())) + .send(RelayEvent::Event(Box::new(*event), subscription_id.clone())) .await .is_err() { -- cgit v1.2.3