From d76003b629a4a03dba23a8a1c41da6e4ac4c30cf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Feb 2026 17:12:17 +0000 Subject: feat: upgrade repo to Full sync and trigger PR event subscription after announcement promotion When git data arrives for a purgatory announcement and promotes it to the database, the relay now: 1. Upgrades the announcement's sync level in RepoSyncIndex from StateOnly to Full (git/sync.rs: process_purgatory_announcements) 2. Sends AddFilters actions to SyncManager for all connected relays, using Full sync filters (Layer 2 #a/#A/#q) to subscribe to PR events (purgatory/sync/context.rs: RealSyncContext.process_newly_available_git_data) 3. For user-submitted purgatory announcements, registers the repo in RepoSyncIndex with StateOnly level and sends AddFilters to SyncManager so it discovers and connects to relays listed in the announcement tags (nostr/builder.rs: handle_announcement AcceptPurgatory path) The RealSyncContext now accepts optional repo_sync_index and sync_action_tx parameters. main.rs wires these up from SyncManager. PolicyContext gains repo_sync_index and sync_action_tx fields for the write policy path. --- src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index ab6ede7..3ff30fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,6 +132,24 @@ async fn main() -> Result<()> { // Get a reference to the rejected events index for shutdown persistence let shutdown_rejected_index = sync_manager.rejected_events_index(); + // Get a reference to the repo sync index for upgrading sync levels on promotion + let repo_sync_index = sync_manager.repo_sync_index(); + + // Set the repo sync index on the write policy so user-submitted purgatory + // announcements can trigger relay discovery (connect to relays in announcement tags) + relay_with_db + .write_policy + .set_repo_sync_index(repo_sync_index.clone()); + + // Get the action sender BEFORE consuming sync_manager with spawn + let action_tx = sync_manager.action_tx(); + + // Set the sync action sender so the write policy can trigger relay connections + // when user-submitted purgatory announcements are registered with StateOnly level + if let Some(tx) = action_tx.clone() { + relay_with_db.write_policy.set_sync_action_tx(tx); + } + tokio::spawn(async move { sync_manager.run().await; }); @@ -184,6 +202,8 @@ async fn main() -> Result<()> { Some(config.domain.clone()), Some(relay_with_db.relay.clone()), git_naughty_list.clone(), + Some(repo_sync_index), + action_tx, )); // Create throttle manager for rate limiting remote git servers -- cgit v1.2.3