From b167f1b2ae7edbcab95554b5203d22d9e372c8b5 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 4 Dec 2025 17:03:40 +0000 Subject: feat(sync): Phase 1 MVP - single relay proactive sync - Add src/sync/ module with SyncManager - Add NGIT_SYNC_RELAY_URL config option - Subscribe to kind 30617 on configured relay - Validate synced events through Nip34WritePolicy - Integration test with two TestRelay instances --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 9200cc2..21b351f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use ngit_grasp::{ http, metrics::Metrics, nostr, + sync::SyncManager, }; #[tokio::main] @@ -50,6 +51,21 @@ async fn main() -> Result<()> { config.domain ); + // Start SyncManager if sync_relay_url is configured + if let Some(ref sync_url) = config.sync_relay_url { + info!("Starting proactive sync from: {}", sync_url); + let sync_manager = SyncManager::new( + sync_url.clone(), + relay_with_db.database.clone(), + relay_with_db.write_policy.clone(), + ); + tokio::spawn(async move { + sync_manager.run().await; + }); + } else { + info!("Proactive sync disabled (no NGIT_SYNC_RELAY_URL configured)"); + } + // Start HTTP server with integrated relay and database info!("Starting HTTP server on {}", config.bind_address); http::run_server(config, relay_with_db.relay, relay_with_db.database, metrics).await?; -- cgit v1.2.3