Skip to content

Commit

Permalink
relay-builder: add LocalRelay::notify_event
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Dec 27, 2024
1 parent 60a10b1 commit 748951d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/nostr-relay-builder/src/local/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ impl InnerLocalRelay {
self.hidden_service.as_deref()
}

pub fn notify_event(&self, event: Event) -> bool {
self.new_event.send(event).is_ok()
}

#[inline]
pub fn shutdown(&self) {
let _ = self.shutdown.send(());
Expand Down
10 changes: 10 additions & 0 deletions crates/nostr-relay-builder/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ impl LocalRelay {
self.inner.hidden_service()
}

/// Send event to subscribers
///
/// Return `true` if the event is successfully sent.
///
/// This method doesn't save the event into the database!
/// It's intended to be used ONLY when the database is shared with other apps (i.e. with the nostr-sdk `Client`).
pub fn notify_event(&self, event: Event) -> bool {
self.inner.notify_event(event)
}

/// Shutdown relay
#[inline]
pub fn shutdown(&self) {
Expand Down

0 comments on commit 748951d

Please sign in to comment.