diff --git a/src/main.rs b/src/main.rs index ba215a9..f31c22c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,11 +52,14 @@ pub async fn find_note(app: &Notecrumbs, nip19: &Nip19) -> Result Result = None; let mut profile: Option = None; + let mut ends: i32 = 0; loop { match client.notifications().recv().await? { @@ -88,7 +92,13 @@ pub async fn find_note(app: &Notecrumbs, nip19: &Nip19) -> Result return Ok(FindNoteResult { note, profile }), + RelayMessage::EndOfStoredEvents(_) => { + ends += 1; + let has_any = note.is_some() || profile.is_some(); + if has_any || ends >= num_relays { + return Ok(FindNoteResult { note, profile }); + } + } _ => continue, }, RelayPoolNotification::Stop | RelayPoolNotification::Shutdown => {