upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr/builder.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-04 17:03:40 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-04 17:03:40 +0000
commitb167f1b2ae7edbcab95554b5203d22d9e372c8b5 (patch)
tree39b3bb879302cb6a4eaabded4a5d20f7d0d68ffc /src/nostr/builder.rs
parentfdbc8895e1e9e712882bd854908295a95e7afcb9 (diff)
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
Diffstat (limited to 'src/nostr/builder.rs')
-rw-r--r--src/nostr/builder.rs13
1 files changed, 7 insertions, 6 deletions
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 {
269 } 269 }
270} 270}
271 271
272/// Result of creating a relay - includes both the relay and database 272/// Result of creating a relay - includes relay, database, and write policy
273pub struct RelayWithDatabase { 273pub struct RelayWithDatabase {
274 /// The local relay instance 274 /// The local relay instance
275 pub relay: LocalRelay, 275 pub relay: LocalRelay,
276 /// The database Arc that can be used for direct queries 276 /// The database Arc that can be used for direct queries
277 pub database: SharedDatabase, 277 pub database: SharedDatabase,
278 /// The write policy used for event validation
279 pub write_policy: Nip34WritePolicy,
278} 280}
279 281
280/// Create a configured LocalRelay with full GRASP-01 validation 282/// Create a configured LocalRelay with full GRASP-01 validation
@@ -330,13 +332,11 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
330 // Build relay with GRASP-01 validation 332 // Build relay with GRASP-01 validation
331 // Clone Arc for the write policy so both relay and policy can access the database 333 // Clone Arc for the write policy so both relay and policy can access the database
332 let git_data_path = config.effective_git_data_path(); 334 let git_data_path = config.effective_git_data_path();
335 let write_policy = Nip34WritePolicy::new(&config.domain, database.clone(), &git_data_path);
336
333 let builder = RelayBuilder::default() 337 let builder = RelayBuilder::default()
334 .database(database.clone()) 338 .database(database.clone())
335 .write_policy(Nip34WritePolicy::new( 339 .write_policy(write_policy.clone());
336 &config.domain,
337 database.clone(),
338 &git_data_path,
339 ));
340 340
341 tracing::info!( 341 tracing::info!(
342 "Relay configured with GRASP-01 validation for domain: {}", 342 "Relay configured with GRASP-01 validation for domain: {}",
@@ -346,5 +346,6 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
346 Ok(RelayWithDatabase { 346 Ok(RelayWithDatabase {
347 relay: LocalRelay::new(builder), 347 relay: LocalRelay::new(builder),
348 database, 348 database,
349 write_policy,
349 }) 350 })
350} \ No newline at end of file 351} \ No newline at end of file