From b4da09689ee0bd6ac327a6ed7ffb01e2175e2596 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 5 Dec 2025 16:37:09 +0000 Subject: remove stupid tests and methods --- src/sync/subscription.rs | 71 ++++++++---------------------------------------- 1 file changed, 11 insertions(+), 60 deletions(-) (limited to 'src/sync/subscription.rs') diff --git a/src/sync/subscription.rs b/src/sync/subscription.rs index c37404f..bbeaa2a 100644 --- a/src/sync/subscription.rs +++ b/src/sync/subscription.rs @@ -26,12 +26,6 @@ use super::filter::FilterService; /// Maximum number of filters before consolidation is triggered const CONSOLIDATION_THRESHOLD: usize = 150; -/// Kind 30617 - Repository Announcement (NIP-34) -const KIND_REPOSITORY_ANNOUNCEMENT: u16 = 30617; - -/// Kind 30618 - Maintainer List (NIP-34) -const KIND_MAINTAINER_LIST: u16 = 30618; - /// Manages subscriptions for a single relay connection /// /// Tracks which announcements and events have been subscribed to, @@ -113,10 +107,7 @@ impl SubscriptionManager { // Build Layer 3 filter for this event // Layer 3 filters target events with 'e' tags pointing to this event - let filter = Filter::new().custom_tag( - SingleLetterTag::lowercase(Alphabet::E), - event_id, - ); + let filter = Filter::new().custom_tag(SingleLetterTag::lowercase(Alphabet::E), event_id); Some(vec![filter]) } @@ -212,67 +203,27 @@ impl SubscriptionManager { } }; - // Determine the kind for the coordinate - let kind = event.kind.as_u16(); - if kind != KIND_REPOSITORY_ANNOUNCEMENT && kind != KIND_MAINTAINER_LIST { + // Verify this is an announcement kind + if !matches!(event.kind, Kind::GitRepoAnnouncement | Kind::RepoState) { tracing::warn!( "Event {} is not an announcement (kind {}), cannot build Layer 2 filter", event.id.to_hex(), - kind + event.kind ); return Vec::new(); } // Build the addressable coordinate: kind:pubkey:identifier - let coord = format!("{}:{}:{}", kind, event.pubkey.to_hex(), identifier); + let coord = format!( + "{}:{}:{}", + event.kind.as_u16(), + event.pubkey.to_hex(), + identifier + ); // Create filter with 'a' tag for this coordinate - let filter = Filter::new().custom_tag( - SingleLetterTag::lowercase(Alphabet::A), - coord, - ); + let filter = Filter::new().custom_tag(SingleLetterTag::lowercase(Alphabet::A), coord); vec![filter] } - - /// Check if an event kind is an announcement kind - pub fn is_announcement_kind(kind: u16) -> bool { - kind == KIND_REPOSITORY_ANNOUNCEMENT || kind == KIND_MAINTAINER_LIST - } - - /// Check if an event kind is a PR/Issue/Patch kind that should trigger Layer 3 - pub fn is_pr_issue_kind(kind: u16) -> bool { - matches!( - kind, - 1617 | // Patch proposal (NIP-34) - 1618 | // PR - 1619 | // PR Update - 1621 | // Issue - 1622 // Reply - ) - } } - -#[cfg(test)] -mod tests { - use super::SubscriptionManager; - - #[test] - fn test_is_announcement_kind() { - assert!(SubscriptionManager::is_announcement_kind(30617)); - assert!(SubscriptionManager::is_announcement_kind(30618)); - assert!(!SubscriptionManager::is_announcement_kind(1)); - assert!(!SubscriptionManager::is_announcement_kind(1617)); - } - - #[test] - fn test_is_pr_issue_kind() { - assert!(SubscriptionManager::is_pr_issue_kind(1617)); - assert!(SubscriptionManager::is_pr_issue_kind(1618)); - assert!(SubscriptionManager::is_pr_issue_kind(1619)); - assert!(SubscriptionManager::is_pr_issue_kind(1621)); - assert!(SubscriptionManager::is_pr_issue_kind(1622)); - assert!(!SubscriptionManager::is_pr_issue_kind(30617)); - assert!(!SubscriptionManager::is_pr_issue_kind(1)); - } -} \ No newline at end of file -- cgit v1.2.3