From ba335aed2aabd0558519816346bdc64c475ff010 Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Tue, 2 Jun 2026 11:32:39 +1000 Subject: [PATCH] refactor(serverless): remove dead code introduced on branch - Delete orphaned HarnessRelay::connect() wrapper (callers use connect_with_mode); fold its doc into connect_with_mode. - Gate BgState::new() behind #[cfg(test)] (test-only now that the runtime path uses with_serverless) instead of #[allow(dead_code)]. - Move KIND_GIFT_WRAP into the encrypted test module (test-only). No #[allow(dead_code)] / cfg_attr dead-code suppressions remain on branch-new code. Verified with RUSTFLAGS='-D dead_code -D unused'. --- crates/sprout-acp/src/relay.rs | 22 +++++----------------- desktop/src-tauri/src/encrypted.rs | 7 +++---- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/crates/sprout-acp/src/relay.rs b/crates/sprout-acp/src/relay.rs index f7a7e26eee..01fe1b9592 100644 --- a/crates/sprout-acp/src/relay.rs +++ b/crates/sprout-acp/src/relay.rs @@ -656,24 +656,12 @@ impl RelayEventPublisher { impl HarnessRelay { // ── Public API ──────────────────────────────────────────────────────────── - /// Connect to relay and authenticate via NIP-42. + /// Connect to the relay, optionally in serverless mode (generic relay, AUTH + /// optional, plain-WS reads/writes). In server mode (`serverless = false`) + /// the NIP-42 AUTH handshake is performed; in serverless mode it is skipped. /// /// `auth_tag` is an optional NIP-OA owner attestation included in the AUTH /// event for relay membership delegation. - /// Server-mode convenience wrapper around [`HarnessRelay::connect_with_mode`]. - /// Kept as part of the public API; the binary uses `connect_with_mode`. - #[allow(dead_code)] - pub async fn connect( - relay_url: &str, - keys: &Keys, - agent_pubkey_hex: &str, - auth_tag: Option, - ) -> Result { - Self::connect_with_mode(relay_url, keys, agent_pubkey_hex, auth_tag, false).await - } - - /// Connect, optionally in serverless mode (generic relay, AUTH optional, - /// plain-WS reads/writes). See [`HarnessRelay::connect`]. pub async fn connect_with_mode( relay_url: &str, keys: &Keys, @@ -1133,9 +1121,9 @@ struct BgState { } impl BgState { - /// Server-mode constructor. Used by unit tests; the runtime path uses + /// Server-mode constructor. Test-only; the runtime path uses /// [`BgState::with_serverless`]. - #[allow(dead_code)] + #[cfg(test)] fn new() -> Self { Self::with_serverless(false) } diff --git a/desktop/src-tauri/src/encrypted.rs b/desktop/src-tauri/src/encrypted.rs index f80beee66f..bef7608954 100644 --- a/desktop/src-tauri/src/encrypted.rs +++ b/desktop/src-tauri/src/encrypted.rs @@ -26,10 +26,6 @@ use nostr::nips::nip59::UnwrappedGift; use nostr::{Event, EventBuilder, Keys, PublicKey, UnsignedEvent}; -/// Kind 1059 — NIP-59 gift wrap. -#[cfg_attr(not(test), allow(dead_code))] -pub const KIND_GIFT_WRAP: u16 = 1059; - /// Build the gift-wrapped events for `rumor`, one per recipient pubkey. /// /// `rumor` is the unsigned inner event (a normal kind-9 message with the `h` @@ -99,6 +95,9 @@ impl UnwrappedRumor { #[cfg(test)] mod tests { use super::*; + + /// Kind 1059 — NIP-59 gift wrap (test-only constant). + const KIND_GIFT_WRAP: u16 = 1059; use nostr::Kind; fn rumor(sender: &Keys, channel_id: &str, content: &str) -> UnsignedEvent {