From 542e70b8e09f2c032669116b253747f9867782ed Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sun, 19 Jul 2026 03:34:29 -0400 Subject: [PATCH] chore: satisfy clippy 1.95 (-D warnings) across the branch - admin.rs: make the config/invite JSON response structs pub (they are returned from pub handlers; matches the already-pub AdminKeyView etc.) - invite_codes/operator_settings: drop redundant reborrow (&mut *tx -> &mut tx) - electrum: minimize a boolean (De Morgan, behavior-identical) - relay: move the test module to end of file (items_after_test_module) Pure lint hygiene surfaced by the current stable toolchain; no behavior change. cargo clippy --all-targets -- -D warnings is now clean. --- src/api/admin.rs | 10 ++++---- src/infra/db/invite_codes.rs | 2 +- src/infra/db/operator_settings.rs | 2 +- src/infra/electrum.rs | 2 +- src/infra/relay/mod.rs | 42 +++++++++++++++---------------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/api/admin.rs b/src/api/admin.rs index 30b980d..55adc8d 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -746,7 +746,7 @@ pub async fn admin_features( // effective config for runtime-safe edits or flags restart-required. #[derive(serde::Serialize)] -struct AdminConfigResponse { +pub struct AdminConfigResponse { /// Effective value of every editable field (all populated). effective: crate::config_overlay::SettingsOverlay, /// DB overlay (operator-set values only): a field present here has source=db; @@ -812,7 +812,7 @@ pub struct PutConfigRequest { } #[derive(serde::Serialize)] -struct PutConfigResponse { +pub struct PutConfigResponse { /// "runtime" = hot-swapped, live now. "restart-required" = persisted, applies on /// the next (graceful) restart. applied: String, @@ -954,7 +954,7 @@ pub struct MintInvitesRequest { } #[derive(serde::Serialize)] -struct MintInvitesResponse { +pub struct MintInvitesResponse { /// RAW single-use codes — shown ONCE (only the hash is stored, unrecoverable). codes: Vec, } @@ -984,7 +984,7 @@ pub async fn admin_invites_mint( } #[derive(serde::Serialize)] -struct InviteView { +pub struct InviteView { /// Non-secret: first 12 hex chars of the code hash (operator eyeball only). code_prefix: String, label: Option, @@ -994,7 +994,7 @@ struct InviteView { } #[derive(serde::Serialize)] -struct InvitesListResponse { +pub struct InvitesListResponse { invites: Vec, unused_count: i64, } diff --git a/src/infra/db/invite_codes.rs b/src/infra/db/invite_codes.rs index 303e23b..ba657bd 100644 --- a/src/infra/db/invite_codes.rs +++ b/src/infra/db/invite_codes.rs @@ -112,7 +112,7 @@ impl Database { .await?; codes.push(code); } - self.append_admin_audit(&mut *tx, audit, secret).await?; + self.append_admin_audit(&mut tx, audit, secret).await?; tx.commit().await?; Ok(codes) } diff --git a/src/infra/db/operator_settings.rs b/src/infra/db/operator_settings.rs index 2efc38f..af336c4 100644 --- a/src/infra/db/operator_settings.rs +++ b/src/infra/db/operator_settings.rs @@ -148,7 +148,7 @@ impl Database { .execute(&mut *tx) .await?; - self.append_admin_audit(&mut *tx, audit, secret).await?; + self.append_admin_audit(&mut tx, audit, secret).await?; tx.commit().await?; Ok(version) } diff --git a/src/infra/electrum.rs b/src/infra/electrum.rs index 3f485ee..a5742f0 100644 --- a/src/infra/electrum.rs +++ b/src/infra/electrum.rs @@ -489,7 +489,7 @@ impl ElectrumClient { let use_primary = self .primary .as_ref() - .filter(|_| !(self.primary_in_cooldown(now) && !self.fallbacks.is_empty())); + .filter(|_| !self.primary_in_cooldown(now) || self.fallbacks.is_empty()); let mut last_err = AppError::NodeError("all Electrum servers failed".into()); diff --git a/src/infra/relay/mod.rs b/src/infra/relay/mod.rs index 2455838..e8f0efd 100644 --- a/src/infra/relay/mod.rs +++ b/src/infra/relay/mod.rs @@ -145,6 +145,27 @@ struct NostrRelayProvider { write_allowlist: HashSet, } +impl RelayProvider for NostrRelayProvider { + fn kind(&self) -> &'static str { + self.kind + } + fn advertised_url(&self) -> &str { + &self.advertised_url + } + fn write_policy(&self) -> WritePolicy { + self.policy + } + fn inbound_pow_bits(&self) -> u8 { + self.inbound_pow_bits + } + fn max_event_bytes(&self) -> usize { + self.max_event_bytes + } + fn is_write_allowlisted(&self, author_hex: &str) -> bool { + !self.write_allowlist.is_empty() && self.write_allowlist.contains(author_hex) + } +} + #[cfg(test)] mod tests { use super::allowlist_entry_to_hex; @@ -175,24 +196,3 @@ mod tests { assert_eq!(allowlist_entry_to_hex("deadbeef"), None); // too short } } - -impl RelayProvider for NostrRelayProvider { - fn kind(&self) -> &'static str { - self.kind - } - fn advertised_url(&self) -> &str { - &self.advertised_url - } - fn write_policy(&self) -> WritePolicy { - self.policy - } - fn inbound_pow_bits(&self) -> u8 { - self.inbound_pow_bits - } - fn max_event_bytes(&self) -> usize { - self.max_event_bytes - } - fn is_write_allowlisted(&self, author_hex: &str) -> bool { - !self.write_allowlist.is_empty() && self.write_allowlist.contains(author_hex) - } -}