From 1df90c609399c675e629b97294aee81a0b1e66dd Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 22 Dec 2025 21:02:03 +0000 Subject: chore: bump rust-nostr to latest master so we can more easily support grasp purgatory feature --- Cargo.lock | 127 +++++---------------- Cargo.toml | 6 +- grasp-audit/Cargo.toml | 2 +- grasp-audit/src/audit.rs | 6 +- grasp-audit/src/fixtures.rs | 14 +-- .../src/specs/grasp01/event_acceptance_policy.rs | 4 +- grasp-audit/src/specs/grasp01/nip01_smoke.rs | 4 +- .../src/specs/grasp01/push_authorization.rs | 2 +- src/main.rs | 2 +- src/nostr/builder.rs | 56 ++++----- src/sync/mod.rs | 12 +- 11 files changed, 85 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f7835b..fbcc015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,6 +270,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "btreecap" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6160c957d8aa33d0a8ba1dbab98e3cb57023ad9374c501441e88559f99e6c4c9" + [[package]] name = "bumpalo" version = "3.19.0" @@ -463,7 +469,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core 0.6.4", "typenum", ] @@ -772,7 +777,7 @@ dependencies = [ "chrono", "clap", "futures", - "nostr-sdk 0.43.0", + "nostr-sdk", "regex", "reqwest 0.11.27", "serde", @@ -1245,9 +1250,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -1436,7 +1438,7 @@ dependencies = [ "lazy_static", "nostr-lmdb", "nostr-relay-builder", - "nostr-sdk 0.44.1", + "nostr-sdk", "prometheus", "rand 0.8.5", "reqwest 0.12.24", @@ -1451,34 +1453,10 @@ dependencies = [ "url", ] -[[package]] -name = "nostr" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a97d745f1bd8d5e05a978632bbb87b0614567d5142906fe7c86fb2440faac6" -dependencies = [ - "base64 0.22.1", - "bech32", - "bip39", - "bitcoin_hashes 0.14.0", - "cbc", - "chacha20", - "chacha20poly1305", - "getrandom 0.2.16", - "instant", - "scrypt", - "secp256k1", - "serde", - "serde_json", - "unicode-normalization", - "url", -] - [[package]] name = "nostr" version = "0.44.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3595fecf0e0aaacb69a0dc0101a4453f3c76eda333d6bbc49f68f64390b3d85" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ "base64 0.22.1", "bech32", @@ -1487,9 +1465,10 @@ dependencies = [ "cbc", "chacha20", "chacha20poly1305", - "getrandom 0.2.16", "hex", "instant", + "once_cell", + "rand 0.9.2", "scrypt", "secp256k1", "serde", @@ -1498,49 +1477,36 @@ dependencies = [ "url", ] -[[package]] -name = "nostr-database" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c75a8c2175d2785ba73cfddef21d1e30da5fbbdf158569b6808ba44973a15b" -dependencies = [ - "lru", - "nostr 0.43.1", - "tokio", -] - [[package]] name = "nostr-database" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7462c9d8ae5ef6a28d66a192d399ad2530f1f2130b13186296dbb11bdef5b3d1" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ + "btreecap", "flatbuffers", "lru", - "nostr 0.44.1", + "nostr", "tokio", ] [[package]] name = "nostr-gossip" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade30de16869618919c6b5efc8258f47b654a98b51541eb77f85e8ec5e3c83a6" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ - "nostr 0.44.1", + "nostr", ] [[package]] name = "nostr-lmdb" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1201bcf1f900c352f9f2cea5249960dc6b23049b65699a516e1327243becf6a2" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ "async-utility", "flume", "heed", - "nostr 0.44.1", - "nostr-database 0.44.0", + "nostr", + "nostr-database", "tokio", "tracing", ] @@ -1548,33 +1514,16 @@ dependencies = [ [[package]] name = "nostr-relay-builder" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ba8e48eaadd5644e7317ca2f892b89a394a8cc57e99fea9f624dc081df1a24" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ "async-utility", "async-wsocket", "atomic-destructor", "hex", "negentropy", - "nostr 0.44.1", - "nostr-database 0.44.0", - "tokio", - "tracing", -] - -[[package]] -name = "nostr-relay-pool" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2f43b70d13dfc50508a13cd902e11f4625312b2ce0e4b7c4c2283fd04001bd" -dependencies = [ - "async-utility", - "async-wsocket", - "atomic-destructor", - "lru", - "negentropy", - "nostr 0.43.1", - "nostr-database 0.43.0", + "nostr", + "nostr-database", + "nostr-relay-pool", "tokio", "tracing", ] @@ -1582,8 +1531,7 @@ dependencies = [ [[package]] name = "nostr-relay-pool" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b1073ccfbaea5549fb914a9d52c68dab2aecda61535e5143dd73e95445a804b" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ "async-utility", "async-wsocket", @@ -1591,36 +1539,22 @@ dependencies = [ "hex", "lru", "negentropy", - "nostr 0.44.1", - "nostr-database 0.44.0", + "nostr", + "nostr-database", "tokio", "tracing", ] -[[package]] -name = "nostr-sdk" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599f8963d6a1522a13b1a2b0ea6e168acfc367706606f1d33fa595e91fa22db0" -dependencies = [ - "async-utility", - "nostr 0.43.1", - "nostr-database 0.43.0", - "nostr-relay-pool 0.43.1", - "tokio", -] - [[package]] name = "nostr-sdk" version = "0.44.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "471732576710e779b64f04c55e3f8b5292f865fea228436daf19694f0bf70393" +source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3" dependencies = [ "async-utility", - "nostr 0.44.1", - "nostr-database 0.44.0", + "nostr", + "nostr-database", "nostr-gossip", - "nostr-relay-pool 0.44.0", + "nostr-relay-pool", "tokio", "tracing", ] @@ -2209,7 +2143,6 @@ version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ - "rand 0.8.5", "secp256k1-sys", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index d1650e0..e1e1627 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,11 +17,11 @@ hyper-util = { version = "0.1", features = ["tokio", "server", "http1", "http2"] http-body-util = "0.1" # Nostr relay -nostr-relay-builder = "0.44" +nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" } # Nostr -nostr-sdk = "0.44" -nostr-lmdb = "0.44" +nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" } +nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" } # Utilities futures-util = "0.3" diff --git a/grasp-audit/Cargo.toml b/grasp-audit/Cargo.toml index 9198cd5..88f3d60 100644 --- a/grasp-audit/Cargo.toml +++ b/grasp-audit/Cargo.toml @@ -12,7 +12,7 @@ path = "src/bin/grasp-audit.rs" [dependencies] # Nostr -nostr-sdk = "0.43" +nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" } # Async tokio = { version = "1", features = ["full"] } diff --git a/grasp-audit/src/audit.rs b/grasp-audit/src/audit.rs index 0a4df42..5fb6904 100644 --- a/grasp-audit/src/audit.rs +++ b/grasp-audit/src/audit.rs @@ -132,7 +132,7 @@ impl AuditConfig { TagKind::SingleLetter(t_tag), vec![format!( "audit-cleanup-after-{}", - self.cleanup_after.as_u64() + self.cleanup_after.as_secs() )], ), ] @@ -328,7 +328,7 @@ mod tests { let after = Timestamp::now(); // Event timestamp should be between before and after (inclusive) - assert!(event.created_at.as_u64() >= before.as_u64()); - assert!(event.created_at.as_u64() <= after.as_u64()); + assert!(event.created_at.as_secs() >= before.as_secs()); + assert!(event.created_at.as_secs() <= after.as_secs()); } } diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index a15bd79..62f93e8 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs @@ -676,7 +676,7 @@ impl<'a> TestContext<'a> { .to_string(); // Create state announcement with deterministic commit hash - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago // Tag format: ["refs/heads/main", ""] @@ -712,7 +712,7 @@ impl<'a> TestContext<'a> { .to_string(); // Create PR event 1 second in the past - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let pr_timestamp = Timestamp::from(base_time - 1); // Build NIP-34 PR event (kind 1618) @@ -755,7 +755,7 @@ impl<'a> TestContext<'a> { .to_string(); // Create PR event 1 second in the past - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let pr_timestamp = Timestamp::from(base_time - 1); // Build NIP-34 PR event (kind 1618) @@ -883,7 +883,7 @@ impl<'a> TestContext<'a> { let repo_id = self.extract_repo_id(&repo)?; // Build state event - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago let state_event = self @@ -1036,7 +1036,7 @@ impl<'a> TestContext<'a> { let repo = self.get_cached_dependency(FixtureKind::ValidRepo)?; // Build maintainer's state event (state event ONLY - no announcement) - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let maintainer_timestamp = Timestamp::from(base_time - 5); // 5 seconds ago (more recent than owner's state) let maintainer_state_event = self @@ -1187,7 +1187,7 @@ impl<'a> TestContext<'a> { self.client.send_event(maintainer_announcement).await?; // Build recursive maintainer's state event - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let recursive_maintainer_timestamp = Timestamp::from(base_time - 2); // 2 seconds ago (most recent) let recursive_maintainer_state_event = self @@ -1338,7 +1338,7 @@ impl<'a> TestContext<'a> { // ============================================================ // Use the same commit hash that's already pushed to the relay // but point HEAD to develop branch instead of main - let base_time = Timestamp::now().as_u64(); + let base_time = Timestamp::now().as_secs(); let develop_timestamp = Timestamp::from(base_time - 1); // 1 second ago (most recent) let develop_state_event = self diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs index c34fe66..00a48fd 100644 --- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs +++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs @@ -271,7 +271,7 @@ impl EventAcceptancePolicyTests { .to_string(); // Create unique repository identifier - let timestamp = Timestamp::now().as_u64(); + let timestamp = Timestamp::now().as_secs(); let repo_id = format!("test-repo-no-clone-{}", timestamp); // Create repo announcement WITHOUT service in clone tag @@ -352,7 +352,7 @@ impl EventAcceptancePolicyTests { .replace("wss://", "https://"); // Create unique repository identifier - let timestamp = Timestamp::now().as_u64(); + let timestamp = Timestamp::now().as_secs(); let repo_id = format!("test-repo-no-relays-{}", timestamp); // Create repo announcement WITHOUT service in relays tag diff --git a/grasp-audit/src/specs/grasp01/nip01_smoke.rs b/grasp-audit/src/specs/grasp01/nip01_smoke.rs index 4dbcd3d..bd45ea4 100644 --- a/grasp-audit/src/specs/grasp01/nip01_smoke.rs +++ b/grasp-audit/src/specs/grasp01/nip01_smoke.rs @@ -216,7 +216,7 @@ impl Nip01SmokeTests { let invalid_event_json = serde_json::json!({ "id": event.id.to_hex(), "pubkey": event.pubkey.to_hex(), - "created_at": event.created_at.as_u64(), + "created_at": event.created_at.as_secs(), "kind": event.kind.as_u16(), "tags": event.tags, "content": event.content, @@ -261,7 +261,7 @@ impl Nip01SmokeTests { let invalid_event_json = serde_json::json!({ "id": EventId::all_zeros().to_hex(), // Wrong ID! "pubkey": event.pubkey.to_hex(), - "created_at": event.created_at.as_u64(), + "created_at": event.created_at.as_secs(), "kind": event.kind.as_u16(), "tags": event.tags, "content": event.content, diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs index ec08032..25738d1 100644 --- a/grasp-audit/src/specs/grasp01/push_authorization.rs +++ b/grasp-audit/src/specs/grasp01/push_authorization.rs @@ -29,7 +29,7 @@ /// /// Run `test_pr_test_commit_hash_discovery` to discover/verify this value. #[allow(dead_code)] -const PR_TEST_COMMIT_HASH: &str = "5d40fb1555a0c28bf4d650515a73aaa54d4d9bfb"; +const PR_TEST_COMMIT_HASH: &str = "8935183ff722bf04e861928c6a7e50868c6ca4a6"; use crate::{ clone_repo, create_commit, create_deterministic_commit_with_variant, try_push, try_push_to_ref, diff --git a/src/main.rs b/src/main.rs index 6d8b4dd..ddb198e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,7 @@ async fn main() -> Result<()> { // Create Nostr relay with NIP-34 validation // Returns both the relay and database for direct queries in handlers - if let Ok(relay_with_db) = nostr::builder::create_relay(&config) { + if let Ok(relay_with_db) = nostr::builder::create_relay(&config).await { info!( "Relay created with NIP-34 validation for domain: {}", config.domain diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs index 84d8ab4..8dd6291 100644 --- a/src/nostr/builder.rs +++ b/src/nostr/builder.rs @@ -3,11 +3,12 @@ /// This module integrates nostr-relay-builder with NIP-34 validation logic /// using modular sub-policies for each event type. use std::net::SocketAddr; +use std::num::NonZeroUsize; use std::path::Path; use std::sync::Arc; use nostr::nips::nip19::ToBech32; -use nostr_lmdb::NostrLMDB; +use nostr_lmdb::NostrLmdb; use nostr_relay_builder::prelude::*; use crate::config::{Config, DatabaseBackend}; @@ -68,7 +69,7 @@ impl Nip34WritePolicy { } /// Handle repository announcement event - async fn handle_announcement(&self, event: &Event) -> PolicyResult { + async fn handle_announcement(&self, event: &Event) -> WritePolicyResult { let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); match self.announcement_policy.validate(event).await { @@ -90,7 +91,7 @@ impl Nip34WritePolicy { } tracing::debug!("Accepted repository announcement: {}", event_id_str); - PolicyResult::Accept + WritePolicyResult::Accept } Err(e) => { tracing::warn!( @@ -98,7 +99,7 @@ impl Nip34WritePolicy { event_id_str, e ); - PolicyResult::Reject(format!("Failed to parse announcement: {}", e)) + WritePolicyResult::reject(format!("Failed to parse announcement: {}", e)) } } } @@ -113,7 +114,7 @@ impl Nip34WritePolicy { announcement.identifier ); // Don't create bare repository for external announcements - PolicyResult::Accept + WritePolicyResult::Accept } Err(e) => { tracing::warn!( @@ -121,7 +122,7 @@ impl Nip34WritePolicy { event_id_str, e ); - PolicyResult::Reject(format!("Failed to parse announcement: {}", e)) + WritePolicyResult::reject(format!("Failed to parse announcement: {}", e)) } } } @@ -131,13 +132,13 @@ impl Nip34WritePolicy { event_id_str, reason ); - PolicyResult::Reject(reason) + WritePolicyResult::reject(reason) } } } /// Handle repository state event - async fn handle_state(&self, event: &Event) -> PolicyResult { + async fn handle_state(&self, event: &Event) -> WritePolicyResult { let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); match self.state_policy.validate(event) { @@ -151,25 +152,25 @@ impl Nip34WritePolicy { } tracing::debug!("Accepted repository state: {}", event_id_str); - PolicyResult::Accept + WritePolicyResult::Accept } Err(e) => { tracing::warn!("Failed to parse repository state {}: {}", event_id_str, e); // Still accept the event even if we can't parse it // The validation passed, so it's structurally valid - PolicyResult::Accept + WritePolicyResult::Accept } } } StateResult::Reject(reason) => { tracing::warn!("Rejected repository state {}: {}", event_id_str, reason); - PolicyResult::Reject(reason) + WritePolicyResult::reject(reason) } } } /// Handle PR or PR Update event - async fn handle_pr_event(&self, event: &Event) -> PolicyResult { + async fn handle_pr_event(&self, event: &Event) -> WritePolicyResult { let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); // Validate refs/nostr refs for this PR event @@ -188,7 +189,7 @@ impl Nip34WritePolicy { } /// Handle events that must reference accepted repositories or events - async fn handle_related_event(&self, event: &Event, event_type: &str) -> PolicyResult { + async fn handle_related_event(&self, event: &Event, event_type: &str) -> WritePolicyResult { let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); match self.related_event_policy.check_references(event).await { @@ -199,7 +200,7 @@ impl Nip34WritePolicy { event_id_str, addr_ref ); - PolicyResult::Accept + WritePolicyResult::Accept } Ok(ReferenceResult::ReferencesEvent(event_ref)) => { tracing::debug!( @@ -208,7 +209,7 @@ impl Nip34WritePolicy { event_id_str, event_ref ); - PolicyResult::Accept + WritePolicyResult::Accept } Ok(ReferenceResult::ReferencedByAccepted) => { tracing::debug!( @@ -216,7 +217,7 @@ impl Nip34WritePolicy { event_type, event_id_str ); - PolicyResult::Accept + WritePolicyResult::Accept } Ok(ReferenceResult::Orphan) => { let (addressable_refs, event_refs) = @@ -228,7 +229,7 @@ impl Nip34WritePolicy { addressable_refs.len(), event_refs.len() ); - PolicyResult::Reject(format!( + WritePolicyResult::reject(format!( "{} event must reference an accepted repository or accepted event", event_type )) @@ -240,7 +241,7 @@ impl Nip34WritePolicy { event_id_str, e ); - PolicyResult::Reject(format!("Database query failed: {}", e)) + WritePolicyResult::reject(format!("Database query failed: {}", e)) } } } @@ -251,7 +252,7 @@ impl WritePolicy for Nip34WritePolicy { &'a self, event: &'a nostr_relay_builder::prelude::Event, _addr: &'a SocketAddr, - ) -> BoxedFuture<'a, PolicyResult> { + ) -> BoxedFuture<'a, WritePolicyResult> { Box::pin(async move { match event.kind.as_u16() { KIND_REPOSITORY_ANNOUNCEMENT => self.handle_announcement(event).await, @@ -265,7 +266,7 @@ impl WritePolicy for Nip34WritePolicy { author = %event.pubkey.to_hex(), "Accepted kind 10317 user grasp list" ); - PolicyResult::Accept + WritePolicyResult::Accept } _ => self.handle_related_event(event, "Event").await, } @@ -288,7 +289,7 @@ pub struct RelayWithDatabase { /// Returns a `RelayWithDatabase` struct containing: /// - The `LocalRelay` for handling WebSocket connections /// - The `SharedDatabase` for direct database queries (e.g., push authorization) -pub fn create_relay(config: &Config) -> Result { +pub async fn create_relay(config: &Config) -> Result { tracing::info!("Configuring nostr relay with GRASP-01 validation..."); // Determine database path @@ -300,7 +301,7 @@ pub fn create_relay(config: &Config) -> Result { tracing::info!("Using in-memory database (no persistence)"); Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions { events: true, - max_events: Some(100_000), + max_events: Some(NonZeroUsize::new(100_000).unwrap()), })) } DatabaseBackend::NostrDb => { @@ -310,7 +311,7 @@ pub fn create_relay(config: &Config) -> Result { tracing::warn!("NostrDB backend not yet implemented, using in-memory database"); Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions { events: true, - max_events: Some(100_000), + max_events: Some(NonZeroUsize::new(100_000).unwrap()), })) } DatabaseBackend::Lmdb => { @@ -323,7 +324,7 @@ pub fn create_relay(config: &Config) -> Result { e ) })?; - Arc::new(NostrLMDB::open(db_path).map_err(|e| { + Arc::new(NostrLmdb::open(db_path).await.map_err(|e| { anyhow::anyhow!( "Failed to open LMDB database at {}: {}", db_path.display(), @@ -338,9 +339,10 @@ pub fn create_relay(config: &Config) -> Result { 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() + let relay = LocalRelayBuilder::default() .database(database.clone()) - .write_policy(write_policy.clone()); + .write_policy(write_policy.clone()) + .build(); tracing::info!( "Relay configured with GRASP-01 validation for domain: {}", @@ -348,7 +350,7 @@ pub fn create_relay(config: &Config) -> Result { ); Ok(RelayWithDatabase { - relay: LocalRelay::new(builder), + relay, database, write_policy, }) diff --git a/src/sync/mod.rs b/src/sync/mod.rs index d315939..6ec39e8 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -260,11 +260,11 @@ async fn run_daily_timer( sync_manager: Arc>, mut shutdown_rx: broadcast::Receiver<()>, ) { - use rand::Rng; + use ::rand::Rng; loop { // Random interval between 23-25 hours - let hours = 23.0 + rand::thread_rng().gen::() * 2.0; + let hours = 23.0 + ::rand::thread_rng().gen::() * 2.0; let seconds = (hours * 3600.0) as u64; tracing::info!( @@ -1599,7 +1599,7 @@ impl SyncManager { write_policy: &Nip34WritePolicy, local_relay: &LocalRelay, ) -> ProcessResult { - use nostr_relay_builder::prelude::{PolicyResult, WritePolicy}; + use nostr_relay_builder::prelude::{WritePolicyResult, WritePolicy}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; // Check if event already exists match database.event_by_id(&event.id).await { @@ -1619,7 +1619,7 @@ impl SyncManager { let result = write_policy.admit_event(event, &dummy_addr).await; match result { - PolicyResult::Accept => { + WritePolicyResult::Accept => { // Save event to database if let Err(e) = database.save_event(event).await { tracing::error!( @@ -1644,11 +1644,11 @@ impl SyncManager { ); ProcessResult::Saved } - PolicyResult::Reject(reason) => { + WritePolicyResult::Reject { message, .. } => { tracing::debug!( event_id = %event.id, relay = %relay_url, - reason = %reason, + reason = %message, "Event rejected by write policy" ); ProcessResult::Rejected -- cgit v1.2.3