upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/purgatory/mod.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 20:32:13 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 20:32:13 +0000
commitee113a654e2971a6ebdb07398cc5638dbe59b48c (patch)
tree6e4aacd207553c367d9b533fd6d4824d34994c82 /src/purgatory/mod.rs
parente7e61d1abfb3609c6818e6040294c6be19ba805f (diff)
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.
Diffstat (limited to 'src/purgatory/mod.rs')
-rw-r--r--src/purgatory/mod.rs17
1 files changed, 17 insertions, 0 deletions
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 {
680 self.announcement_purgatory.len() 680 self.announcement_purgatory.len()
681 } 681 }
682 682
683 /// Collect (repo_id, relay_urls) for all announcements currently in purgatory.
684 ///
685 /// Returns a vec of `(repo_id, relay_urls)` where `repo_id` is the addressable
686 /// coordinate string `"30617:{pubkey_hex}:{identifier}"`. Used by the purgatory
687 /// announcement sync timer to register StateOnly entries in `repo_sync_index`.
688 pub fn announcements_for_sync(&self) -> Vec<(String, HashSet<String>)> {
689 self.announcement_purgatory
690 .iter()
691 .map(|entry| {
692 let (owner, identifier) = entry.key();
693 let repo_id = format!("30617:{}:{}", owner.to_hex(), identifier);
694 let relays = entry.value().relays.clone();
695 (repo_id, relays)
696 })
697 .collect()
698 }
699
683 /// Get all event IDs currently stored in purgatory AND previously expired events. 700 /// Get all event IDs currently stored in purgatory AND previously expired events.
684 /// 701 ///
685 /// Returns a HashSet of all event IDs for: 702 /// Returns a HashSet of all event IDs for: