cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

commit 179724ce5f13a3170e55e78729886ab1edbac67a
parent a27b3a06d0bf350a69b2653fba3aec9818abfed2
Author: triesap <tyson@radroots.org>
Date:   Mon, 25 May 2026 05:24:53 +0000

local-events: use canonical relay fingerprints

Diffstat:
Msrc/runtime/local_events.rs | 21+++------------------
Mtests/target_cli.rs | 16++++++++++++++--
2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/runtime/local_events.rs b/src/runtime/local_events.rs @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use radroots_local_events::{ LocalEventRecord, LocalEventRecordInput, LocalEventsStore, LocalRecordFamily, - LocalRecordStatus, PublishOutboxStatus, SourceRuntime, + LocalRecordStatus, PublishOutboxStatus, SourceRuntime, canonical_relay_set_fingerprint, }; use radroots_runtime_paths::{ default_shared_local_events_database_path_from_shared_accounts_data_root, @@ -69,7 +69,7 @@ pub fn append_signed_event( event: &radroots_nostr::prelude::RadrootsNostrEvent, ) -> Result<LocalEventRecord, RuntimeError> { let timestamp = current_time_ms()?; - let relay_set = relay_set_fingerprint(&config.relay.urls); + let relay_set = canonical_relay_set_fingerprint(&config.relay.urls); let input = LocalEventRecordInput { record_id: format!("cli:signed_event:{subject}:{}", event.id.to_hex()), family: LocalRecordFamily::SignedEvent, @@ -229,7 +229,7 @@ fn update_signed_event_outbox( record_id: record_id.to_owned(), status, outbox_status, - relay_set_fingerprint: relay_set_fingerprint(&config.relay.urls), + relay_set_fingerprint: canonical_relay_set_fingerprint(&config.relay.urls), relay_delivery_json: Some(relay_delivery_json), updated_at_ms: current_time_ms()?, })?, @@ -314,21 +314,6 @@ fn current_time_ms() -> Result<i64, RuntimeError> { .map_err(|_| RuntimeError::Config("current timestamp exceeds i64 milliseconds".to_owned())) } -fn relay_set_fingerprint(relay_urls: &[String]) -> Option<String> { - if relay_urls.is_empty() { - return None; - } - let mut relays = relay_urls - .iter() - .map(|relay| relay.trim()) - .filter(|relay| !relay.is_empty()) - .map(str::to_owned) - .collect::<Vec<_>>(); - relays.sort(); - relays.dedup(); - (!relays.is_empty()).then(|| format!("nostr-relay-set-v1:{}", relays.join(","))) -} - fn pending_delivery_json(relay_urls: &[String]) -> Value { json!({ "state": "pending", diff --git a/tests/target_cli.rs b/tests/target_cli.rs @@ -14,8 +14,9 @@ use radroots_events::trade::{ }; use radroots_events_codec::trade::active_trade_order_request_event_build; use radroots_local_events::{ - BUYER_ORDER_REQUEST_LOCAL_WORK_RECORD_KIND, LocalEventRecordInput, LocalEventsStore, - LocalRecordFamily, LocalRecordStatus, PublishOutboxStatus, SourceRuntime, + BUYER_ORDER_REQUEST_LOCAL_WORK_RECORD_KIND, CANONICAL_RELAY_SET_FINGERPRINT_VERSION, + LocalEventRecordInput, LocalEventsStore, LocalRecordFamily, LocalRecordStatus, + PublishOutboxStatus, SourceRuntime, canonical_relay_set_fingerprint, }; use radroots_nostr::prelude::{RadrootsNostrEvent, radroots_nostr_build_event}; use radroots_replica_db::{farm, farm_member_claim, migrations}; @@ -4831,6 +4832,17 @@ fn farm_publish_writes_acknowledged_signed_outbox_records() { relay_url ); assert_eq!( + record.relay_set_fingerprint.as_deref(), + canonical_relay_set_fingerprint([relay_url.as_str()]).as_deref() + ); + assert!( + record + .relay_set_fingerprint + .as_deref() + .expect("relay set fingerprint") + .starts_with(CANONICAL_RELAY_SET_FINGERPRINT_VERSION) + ); + assert_eq!( record.raw_event_json.as_ref().unwrap()["id"], record.event_id.as_deref().expect("event id") );