From 90a0036c2dc13a9790f8eed81edd73a0ba57796c Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Fri, 20 Oct 2023 12:58:02 +0200 Subject: [PATCH] sdk: revert commit `95d3404c` --- crates/nostr-sdk/src/relay/mod.rs | 85 +++++++++++++------------------ 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/crates/nostr-sdk/src/relay/mod.rs b/crates/nostr-sdk/src/relay/mod.rs index 7bec01425..974497c37 100644 --- a/crates/nostr-sdk/src/relay/mod.rs +++ b/crates/nostr-sdk/src/relay/mod.rs @@ -1015,55 +1015,46 @@ impl Relay { ))); } - if event.is_ephemeral() { - tracing::warn!( - "Trying to send an ephemeral event: skip the wait for `OK` msg from relay." - ); - self.send_msg(ClientMessage::new_event(event), Some(opts.timeout)) - .await?; - Ok(id) - } else { - time::timeout(Some(opts.timeout), async { - self.send_msg(ClientMessage::new_event(event), None).await?; - let mut notifications = self.notification_sender.subscribe(); - while let Ok(notification) = notifications.recv().await { - match notification { - RelayPoolNotification::Message( - url, - RelayMessage::Ok { - event_id, - status, - message, - }, - ) => { - if self.url == url && id == event_id { - if status { - return Ok(event_id); - } else { - return Err(Error::EventNotPublished(message)); - } + time::timeout(Some(opts.timeout), async { + self.send_msg(ClientMessage::new_event(event), None).await?; + let mut notifications = self.notification_sender.subscribe(); + while let Ok(notification) = notifications.recv().await { + match notification { + RelayPoolNotification::Message( + url, + RelayMessage::Ok { + event_id, + status, + message, + }, + ) => { + if self.url == url && id == event_id { + if status { + return Ok(event_id); + } else { + return Err(Error::EventNotPublished(message)); } } - RelayPoolNotification::RelayStatus { url, status } => { - if opts.skip_disconnected && url == self.url { - if let RelayStatus::Disconnected - | RelayStatus::Stopped - | RelayStatus::Terminated = status - { - return Err(Error::EventNotPublished(String::from( - "relay not connected (status changed)", - ))); - } + } + RelayPoolNotification::RelayStatus { url, status } => { + if opts.skip_disconnected && url == self.url { + if let RelayStatus::Disconnected + | RelayStatus::Stopped + | RelayStatus::Terminated = status + { + return Err(Error::EventNotPublished(String::from( + "relay not connected (status changed)", + ))); } } - _ => (), } + _ => (), } - Err(Error::LoopTerminated) - }) - .await - .ok_or(Error::Timeout)? - } + } + Err(Error::LoopTerminated) + }) + .await + .ok_or(Error::Timeout)? } /// Send multiple [`Event`] at once @@ -1090,13 +1081,7 @@ impl Relay { let mut missing: HashSet = HashSet::new(); for event in events.into_iter() { - if !event.is_ephemeral() { - missing.insert(event.id); - } else { - tracing::warn!( - "Trying to batch ephemeral event: skip the wait for `OK` msg from relay." - ); - } + missing.insert(event.id); msgs.push(ClientMessage::new_event(event)); }