diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-18 09:58:41 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-18 09:58:41 +0000 |
| commit | 2f365fc3b209f6d377d59a6ab8a6891b0350fee6 (patch) | |
| tree | f28c26bff17be7672922f19879adc75467700f14 | |
| parent | 28aa19bc5b196f2259ab8ff0ac8534afe886529f (diff) | |
fix: preserve state events when another owner's announcement remains in purgatory
remove_purgatory_announcement() was unconditionally wiping all state
events for an identifier when one owner's announcement was evicted.
State events are keyed by identifier alone, so this incorrectly
discarded state events belonging to a different owner's repository
sharing the same identifier string. Now only removes state events if
no other owner's announcement remains in purgatory for that identifier.
| -rw-r--r-- | src/nostr/policy/announcement.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nostr/policy/announcement.rs b/src/nostr/policy/announcement.rs index 9b92aeb..b366f0b 100644 --- a/src/nostr/policy/announcement.rs +++ b/src/nostr/policy/announcement.rs | |||
| @@ -225,11 +225,23 @@ impl AnnouncementPolicy { | |||
| 225 | // Remove the announcement from purgatory | 225 | // Remove the announcement from purgatory |
| 226 | self.ctx.purgatory.remove_announcement(pubkey, identifier); | 226 | self.ctx.purgatory.remove_announcement(pubkey, identifier); |
| 227 | 227 | ||
| 228 | // Remove any state events waiting for this identifier | 228 | // Only remove state events if no other owner still has an announcement in purgatory |
| 229 | self.ctx.purgatory.remove_state(identifier); | 229 | // for this identifier. State events are keyed by identifier alone, so blindly removing |
| 230 | // them would also discard state events legitimately belonging to a different owner's | ||
| 231 | // repository that happens to share the same identifier string. | ||
| 232 | let other_owners_remain = !self | ||
| 233 | .ctx | ||
| 234 | .purgatory | ||
| 235 | .get_announcements_by_identifier(identifier) | ||
| 236 | .is_empty(); | ||
| 237 | |||
| 238 | if !other_owners_remain { | ||
| 239 | self.ctx.purgatory.remove_state(identifier); | ||
| 240 | } | ||
| 230 | 241 | ||
| 231 | tracing::info!( | 242 | tracing::info!( |
| 232 | identifier = %identifier, | 243 | identifier = %identifier, |
| 244 | other_owners_remain = %other_owners_remain, | ||
| 233 | "Cleared purgatory entry: owner removed our service from announcement" | 245 | "Cleared purgatory entry: owner removed our service from announcement" |
| 234 | ); | 246 | ); |
| 235 | } | 247 | } |