From ee113a654e2971a6ebdb07398cc5638dbe59b48c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Feb 2026 20:32:13 +0000 Subject: fix: replace repo_sync_index wiring with purgatory announcement sync timer Instead of threading repo_sync_index through PolicyContext/builder.rs/main.rs to handle user-submitted purgatory announcements, add a simple background timer (run_purgatory_announcement_sync, every 5s) that scans the purgatory for announcement entries and registers them in repo_sync_index as StateOnly. This is simpler and covers both flows: - Sync-path announcements: inline registration still happens during event processing (sync/mod.rs:1839+), timer provides a safety net - User-submitted announcements: SelfSubscriber never sees them (rejected from DB), timer is the primary registration path The timer calls sync_purgatory_announcements_to_index() which: 1. Snapshots purgatory via new announcements_for_sync() public method 2. Or_inserts StateOnly entries (never downgrades Full entries) 3. Detects newly added relay URLs and calls handle_new_sync_filters to connect and subscribe - fixing the failing test that expected relay discovery from a user-submitted purgatory announcement Removes: repo_sync_index field from PolicyContext, set/get_repo_sync_index methods, set_repo_sync_index on Nip34WritePolicy, wiring in main.rs, and the inline AcceptPurgatory registration block in builder.rs. --- src/purgatory/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/purgatory') diff --git a/src/purgatory/mod.rs b/src/purgatory/mod.rs index 3b5514b..1894738 100644 --- a/src/purgatory/mod.rs +++ b/src/purgatory/mod.rs @@ -680,6 +680,23 @@ impl Purgatory { self.announcement_purgatory.len() } + /// Collect (repo_id, relay_urls) for all announcements currently in purgatory. + /// + /// Returns a vec of `(repo_id, relay_urls)` where `repo_id` is the addressable + /// coordinate string `"30617:{pubkey_hex}:{identifier}"`. Used by the purgatory + /// announcement sync timer to register StateOnly entries in `repo_sync_index`. + pub fn announcements_for_sync(&self) -> Vec<(String, HashSet)> { + self.announcement_purgatory + .iter() + .map(|entry| { + let (owner, identifier) = entry.key(); + let repo_id = format!("30617:{}:{}", owner.to_hex(), identifier); + let relays = entry.value().relays.clone(); + (repo_id, relays) + }) + .collect() + } + /// Get all event IDs currently stored in purgatory AND previously expired events. /// /// Returns a HashSet of all event IDs for: -- cgit v1.2.3