Skip to content

Commit

Permalink
sdk: skip disconnected relay in handle_events_of method
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Oct 5, 2023
1 parent 58a10c0 commit 6e14885
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/nostr-sdk/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub enum Error {
/// Message not sent
#[error("message not sent")]
MessageNotSent,
/// Relay not connected
#[error("relay not connected")]
NotConnected,
/// Event not published
#[error("event not published: {0}")]
EventNotPublished(String),
Expand Down Expand Up @@ -1463,6 +1466,13 @@ impl Relay {
where
F: Future<Output = ()>,
{
if !self.is_connected().await
&& self.stats.attempts() > 1
&& self.stats.uptime() < MIN_UPTIME
{
return Err(Error::NotConnected);
}

let mut counter = 0;
let mut received_eose: bool = false;

Expand Down

0 comments on commit 6e14885

Please sign in to comment.