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/nostr/builder.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/nostr/builder.rs') diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs index 15ff083..2284c18 100644 --- a/src/nostr/builder.rs +++ b/src/nostr/builder.rs @@ -269,12 +269,14 @@ impl WritePolicy for Nip34WritePolicy { } } -/// Result of creating a relay - includes both the relay and database +/// Result of creating a relay - includes relay, database, and write policy pub struct RelayWithDatabase { /// The local relay instance pub relay: LocalRelay, /// The database Arc that can be used for direct queries pub database: SharedDatabase, + /// The write policy used for event validation + pub write_policy: Nip34WritePolicy, } /// Create a configured LocalRelay with full GRASP-01 validation @@ -330,13 +332,11 @@ pub fn create_relay(config: &Config) -> Result { // Build relay with GRASP-01 validation // Clone Arc for the write policy so both relay and policy can access the database let git_data_path = config.effective_git_data_path(); + let write_policy = Nip34WritePolicy::new(&config.domain, database.clone(), &git_data_path); + let builder = RelayBuilder::default() .database(database.clone()) - .write_policy(Nip34WritePolicy::new( - &config.domain, - database.clone(), - &git_data_path, - )); + .write_policy(write_policy.clone()); tracing::info!( "Relay configured with GRASP-01 validation for domain: {}", @@ -346,5 +346,6 @@ pub fn create_relay(config: &Config) -> Result { Ok(RelayWithDatabase { relay: LocalRelay::new(builder), database, + write_policy, }) } \ No newline at end of file -- cgit v1.2.3