From 28aa19bc5b196f2259ab8ff0ac8534afe886529f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Feb 2026 09:43:34 +0000 Subject: fix: only evict purgatory entry when incoming rejected announcement is newer An older rejected announcement (e.g. a relay replay of a superseded event) was incorrectly evicting a newer purgatory entry for the same pubkey+identifier. Now only evict when the incoming event's created_at is strictly greater than the stored entry's created_at. --- src/nostr/policy/announcement.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/nostr/policy/announcement.rs b/src/nostr/policy/announcement.rs index a90ec94..9b92aeb 100644 --- a/src/nostr/policy/announcement.rs +++ b/src/nostr/policy/announcement.rs @@ -56,14 +56,20 @@ impl AnnouncementPolicy { // GRASP-01 Exception: Accept announcements from recursive maintainers match RepositoryAnnouncement::from_event(event.clone()) { Ok(announcement) => { - // If this pubkey+identifier had a purgatory entry, the owner may be - // sending a new announcement that removes our service. Clear the - // purgatory entry and its bare repo so we don't hold stale data. - if self + // If this pubkey+identifier has a purgatory entry AND the incoming + // event is strictly newer, the owner is sending a replacement that + // removes our service. Clear the purgatory entry and its bare repo. + // + // If the incoming event is older than the purgatory entry (e.g. a + // relay replay of a superseded announcement), ignore it — the newer + // purgatory entry takes precedence and must not be evicted. + let should_evict = self .ctx .purgatory - .has_purgatory_announcement(&event.pubkey, &announcement.identifier) - { + .find_announcement(&event.pubkey, &announcement.identifier) + .is_some_and(|entry| event.created_at > entry.event.created_at); + + if should_evict { self.remove_purgatory_announcement(&event.pubkey, &announcement.identifier); } -- cgit v1.2.3