From 2a9160836bb87fdea3ae891563b0169c68d1c2ab Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 11 Dec 2025 16:53:03 +0000 Subject: fix: resolve all fmt and clippy warnings Main lib (src/): - Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration) - Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting) - Replace .or_insert_with(RelaySyncNeeds::default) with .or_default() - Replace manual div_ceil implementations with .div_ceil(100) Test code (tests/): - Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...)) - Remove needless borrows in fetch_metrics() calls - Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module grasp-audit: - Apply cargo fmt to fix formatting --- src/sync/relay_connection.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/sync/relay_connection.rs') diff --git a/src/sync/relay_connection.rs b/src/sync/relay_connection.rs index fae179b..4167a0c 100644 --- a/src/sync/relay_connection.rs +++ b/src/sync/relay_connection.rs @@ -150,17 +150,21 @@ impl RelayConnection { // // See: nostr-sdk-0.44 Client::try_connect_relay documentation self.client - .try_connect_relay(&self.url, std::time::Duration::from_secs(connection_timeout_secs)) + .try_connect_relay( + &self.url, + std::time::Duration::from_secs(connection_timeout_secs), + ) .await .map_err(|e| format!("Failed to connect to relay {}: {}", self.url, e))?; // Subscribe to Layer 1 (announcements) let filter = build_announcement_filter(since); - let output = self - .client - .subscribe(filter, None) - .await - .map_err(|e| format!("Failed to subscribe to announcements on {}: {}", self.url, e))?; + let output = self.client.subscribe(filter, None).await.map_err(|e| { + format!( + "Failed to subscribe to announcements on {}: {}", + self.url, e + ) + })?; tracing::info!(url = %self.url, sub_id = %output.val, "Connected and subscribed to Layer 1 (announcements)"); Ok(output.val) @@ -250,7 +254,8 @@ impl RelayConnection { } RelayMessage::Closed { message: msg, .. } => { tracing::info!(relay = %url, message = %msg, "Relay closed subscription"); - let _ = event_sender.send(RelayEvent::Closed(msg.to_string())).await; + let _ = + event_sender.send(RelayEvent::Closed(msg.to_string())).await; break; } _ => {} @@ -421,7 +426,10 @@ impl RelayConnection { /// - Relay doesn't actually support NIP-77 (despite claiming to) /// - Network errors during reconciliation /// - Timeout during sync - pub async fn negentropy_sync_filter(&self, filter: Filter) -> Result { + pub async fn negentropy_sync_filter( + &self, + filter: Filter, + ) -> Result { // Use nostr-sdk's sync method which handles the NEG-OPEN/NEG-MSG exchange let sync_opts = SyncOptions::default(); -- cgit v1.2.3