feat: integrate nostrdb relay indexing

- Upgrade `nostrdb` to v0.6.1 with relay metadata support
- Switch to `nostr::RelayUrl` for typed relay URLs
- Use `process_event_with()` to pass relay info during ingestion
- Update `Relay`, `RelayPool`, and unknown ID logic accordingly

This enables richer indexing with relay provenance in events.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-21 16:17:32 -07:00
parent a7f34a9dc7
commit 26b58683b8
12 changed files with 52 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ strum = { workspace = true }
strum_macros = { workspace = true }
dirs = { workspace = true }
enostr = { workspace = true }
nostr = { workspace = true }
egui = { workspace = true }
eframe = { workspace = true }
image = { workspace = true }

View File

@@ -5,6 +5,7 @@ use crate::{
};
use enostr::{Filter, NoteId, Pubkey};
use nostr::RelayUrl;
use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction};
use std::collections::{HashMap, HashSet};
use std::time::{Duration, Instant};
@@ -78,8 +79,6 @@ impl SingleUnkIdAction {
}
}
type RelayUrl = String;
/// Unknown Id searcher
#[derive(Default, Debug)]
pub struct UnknownIds {
@@ -300,7 +299,7 @@ pub fn get_unknown_note_ids<'a>(
let id = UnknownId::Pubkey(Pubkey::new(*nprofile.pubkey()));
let relays = nprofile
.relays_iter()
.map(String::from)
.filter_map(|s| RelayUrl::parse(s).ok())
.collect::<HashSet<RelayUrl>>();
ids.entry(id).or_default().extend(relays);
}
@@ -308,7 +307,7 @@ pub fn get_unknown_note_ids<'a>(
Mention::Event(ev) => {
let relays = ev
.relays_iter()
.map(String::from)
.filter_map(|s| RelayUrl::parse(s).ok())
.collect::<HashSet<RelayUrl>>();
match ndb.get_note_by_id(txn, ev.id()) {
Err(_) => {