diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-18 20:32:13 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-18 20:32:13 +0000 |
| commit | ee113a654e2971a6ebdb07398cc5638dbe59b48c (patch) | |
| tree | 6e4aacd207553c367d9b533fd6d4824d34994c82 /src/nostr/policy | |
| parent | e7e61d1abfb3609c6818e6040294c6be19ba805f (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/nostr/policy')
| -rw-r--r-- | src/nostr/policy/mod.rs | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/src/nostr/policy/mod.rs b/src/nostr/policy/mod.rs index c958586..1566b6c 100644 --- a/src/nostr/policy/mod.rs +++ b/src/nostr/policy/mod.rs | |||
| @@ -20,7 +20,6 @@ pub use crate::git::sync::AlignmentResult; | |||
| 20 | 20 | ||
| 21 | use super::SharedDatabase; | 21 | use super::SharedDatabase; |
| 22 | use crate::purgatory::Purgatory; | 22 | use crate::purgatory::Purgatory; |
| 23 | use crate::sync::RepoSyncIndex; | ||
| 24 | use nostr_relay_builder::LocalRelay; | 23 | use nostr_relay_builder::LocalRelay; |
| 25 | use std::sync::Arc; | 24 | use std::sync::Arc; |
| 26 | 25 | ||
| @@ -35,8 +34,6 @@ pub struct PolicyContext { | |||
| 35 | pub local_relay: Arc<std::sync::RwLock<Option<LocalRelay>>>, | 34 | pub local_relay: Arc<std::sync::RwLock<Option<LocalRelay>>>, |
| 36 | /// Configuration reference for policy settings (includes blacklists) | 35 | /// Configuration reference for policy settings (includes blacklists) |
| 37 | pub config: crate::config::Config, | 36 | pub config: crate::config::Config, |
| 38 | /// Repo sync index for registering purgatory announcements (set after SyncManager creation) | ||
| 39 | pub repo_sync_index: Arc<std::sync::RwLock<Option<RepoSyncIndex>>>, | ||
| 40 | } | 37 | } |
| 41 | 38 | ||
| 42 | impl PolicyContext { | 39 | impl PolicyContext { |
| @@ -54,7 +51,6 @@ impl PolicyContext { | |||
| 54 | purgatory, | 51 | purgatory, |
| 55 | local_relay: Arc::new(std::sync::RwLock::new(None)), | 52 | local_relay: Arc::new(std::sync::RwLock::new(None)), |
| 56 | config, | 53 | config, |
| 57 | repo_sync_index: Arc::new(std::sync::RwLock::new(None)), | ||
| 58 | } | 54 | } |
| 59 | } | 55 | } |
| 60 | 56 | ||
| @@ -72,19 +68,4 @@ impl PolicyContext { | |||
| 72 | let guard = self.local_relay.read().unwrap(); | 68 | let guard = self.local_relay.read().unwrap(); |
| 73 | guard.clone() | 69 | guard.clone() |
| 74 | } | 70 | } |
| 75 | |||
| 76 | /// Set the repo sync index after SyncManager has been created. | ||
| 77 | /// | ||
| 78 | /// This allows purgatory announcements submitted by users to be registered | ||
| 79 | /// in the sync index so state event sync starts promptly. | ||
| 80 | pub fn set_repo_sync_index(&self, index: RepoSyncIndex) { | ||
| 81 | let mut guard = self.repo_sync_index.write().unwrap(); | ||
| 82 | *guard = Some(index); | ||
| 83 | } | ||
| 84 | |||
| 85 | /// Get a clone of the repo sync index if it has been set. | ||
| 86 | pub fn get_repo_sync_index(&self) -> Option<RepoSyncIndex> { | ||
| 87 | let guard = self.repo_sync_index.read().unwrap(); | ||
| 88 | guard.clone() | ||
| 89 | } | ||
| 90 | } | 71 | } |