diff options
| -rw-r--r-- | src/nostr/policy/announcement.rs | 18 |
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 | ||