diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
| commit | 2a9160836bb87fdea3ae891563b0169c68d1c2ab (patch) | |
| tree | 583c890687beaf7f380fc0be131bdf17485f06fa /src/nostr/builder.rs | |
| parent | 52489d3b1a7d79e164b4cc901b53fd06c05ce1b1 (diff) | |
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
Diffstat (limited to 'src/nostr/builder.rs')
| -rw-r--r-- | src/nostr/builder.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs index 2284c18..c9bd1e1 100644 --- a/src/nostr/builder.rs +++ b/src/nostr/builder.rs | |||
| @@ -16,8 +16,8 @@ use crate::nostr::events::{ | |||
| 16 | KIND_REPOSITORY_STATE, | 16 | KIND_REPOSITORY_STATE, |
| 17 | }; | 17 | }; |
| 18 | use crate::nostr::policy::{ | 18 | use crate::nostr::policy::{ |
| 19 | AnnouncementPolicy, AnnouncementResult, PolicyContext, PrEventPolicy, RelatedEventPolicy, | 19 | AnnouncementPolicy, AnnouncementResult, PolicyContext, PrEventPolicy, ReferenceResult, |
| 20 | ReferenceResult, StatePolicy, StateResult, | 20 | RelatedEventPolicy, StatePolicy, StateResult, |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | /// Type alias for the shared database used by the relay | 23 | /// Type alias for the shared database used by the relay |
| @@ -77,7 +77,9 @@ impl Nip34WritePolicy { | |||
| 77 | match RepositoryAnnouncement::from_event(event.clone()) { | 77 | match RepositoryAnnouncement::from_event(event.clone()) { |
| 78 | Ok(announcement) => { | 78 | Ok(announcement) => { |
| 79 | // Try to create bare repository if it doesn't exist | 79 | // Try to create bare repository if it doesn't exist |
| 80 | if let Err(e) = self.announcement_policy.ensure_bare_repository(&announcement) | 80 | if let Err(e) = self |
| 81 | .announcement_policy | ||
| 82 | .ensure_bare_repository(&announcement) | ||
| 81 | { | 83 | { |
| 82 | tracing::warn!( | 84 | tracing::warn!( |
| 83 | "Failed to create bare repository for {}: {}", | 85 | "Failed to create bare repository for {}: {}", |
| @@ -145,22 +147,14 @@ impl Nip34WritePolicy { | |||
| 145 | Ok(_state) => { | 147 | Ok(_state) => { |
| 146 | // Process state alignment asynchronously | 148 | // Process state alignment asynchronously |
| 147 | if let Err(e) = self.state_policy.process_state_event(event).await { | 149 | if let Err(e) = self.state_policy.process_state_event(event).await { |
| 148 | tracing::warn!( | 150 | tracing::warn!("Failed to process state event {}: {}", event_id_str, e); |
| 149 | "Failed to process state event {}: {}", | ||
| 150 | event_id_str, | ||
| 151 | e | ||
| 152 | ); | ||
| 153 | } | 151 | } |
| 154 | 152 | ||
| 155 | tracing::debug!("Accepted repository state: {}", event_id_str); | 153 | tracing::debug!("Accepted repository state: {}", event_id_str); |
| 156 | PolicyResult::Accept | 154 | PolicyResult::Accept |
| 157 | } | 155 | } |
| 158 | Err(e) => { | 156 | Err(e) => { |
| 159 | tracing::warn!( | 157 | tracing::warn!("Failed to parse repository state {}: {}", event_id_str, e); |
| 160 | "Failed to parse repository state {}: {}", | ||
| 161 | event_id_str, | ||
| 162 | e | ||
| 163 | ); | ||
| 164 | // Still accept the event even if we can't parse it | 158 | // Still accept the event even if we can't parse it |
| 165 | // The validation passed, so it's structurally valid | 159 | // The validation passed, so it's structurally valid |
| 166 | PolicyResult::Accept | 160 | PolicyResult::Accept |
| @@ -348,4 +342,4 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> { | |||
| 348 | database, | 342 | database, |
| 349 | write_policy, | 343 | write_policy, |
| 350 | }) | 344 | }) |
| 351 | } \ No newline at end of file | 345 | } |