upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 09:43:34 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 09:43:34 +0000
commit28aa19bc5b196f2259ab8ff0ac8534afe886529f (patch)
tree4d7281eb7966b295eb657c326f3a718b44e51693 /src
parent85d621c791efaad1245c1aec8e5185a1eb78c7b9 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/nostr/policy/announcement.rs18
1 files 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 {
56 // GRASP-01 Exception: Accept announcements from recursive maintainers 56 // GRASP-01 Exception: Accept announcements from recursive maintainers
57 match RepositoryAnnouncement::from_event(event.clone()) { 57 match RepositoryAnnouncement::from_event(event.clone()) {
58 Ok(announcement) => { 58 Ok(announcement) => {
59 // If this pubkey+identifier had a purgatory entry, the owner may be 59 // If this pubkey+identifier has a purgatory entry AND the incoming
60 // sending a new announcement that removes our service. Clear the 60 // event is strictly newer, the owner is sending a replacement that
61 // purgatory entry and its bare repo so we don't hold stale data. 61 // removes our service. Clear the purgatory entry and its bare repo.
62 if self 62 //
63 // If the incoming event is older than the purgatory entry (e.g. a
64 // relay replay of a superseded announcement), ignore it — the newer
65 // purgatory entry takes precedence and must not be evicted.
66 let should_evict = self
63 .ctx 67 .ctx
64 .purgatory 68 .purgatory
65 .has_purgatory_announcement(&event.pubkey, &announcement.identifier) 69 .find_announcement(&event.pubkey, &announcement.identifier)
66 { 70 .is_some_and(|entry| event.created_at > entry.event.created_at);
71
72 if should_evict {
67 self.remove_purgatory_announcement(&event.pubkey, &announcement.identifier); 73 self.remove_purgatory_announcement(&event.pubkey, &announcement.identifier);
68 } 74 }
69 75