Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nostr-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

## Unreleased

### Added

- Add `LocalRelay::connections_left` (https://github.com/nostrdevkit/nostr/pull/1459)

### Deprecated

- Deprecate `LocalRelayBuilder::max_query_results` and `LocalRelayBuilder::default_filter_limit` (https://github.com/nostrdevkit/nostr/pull/1461)
Expand Down
2 changes: 1 addition & 1 deletion nostr-sdk/src/local_relay/local/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(super) struct InnerLocalRelay {
auth_events_per_minute: u32,
messages_per_minute: u32,
pending_handshakes_limit: Arc<Semaphore>,
connections_limit: Arc<Semaphore>,
pub(crate) connections_limit: Arc<Semaphore>,
max_websocket_message_size: usize,
max_event_size: usize,
websocket_handshake_timeout: Duration,
Expand Down
6 changes: 6 additions & 0 deletions nostr-sdk/src/local_relay/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ impl LocalRelay {
self.inner.url().await
}

/// Returns the remaining connection capacity before the limit is reached.
#[inline]
pub fn connections_left(&self) -> usize {
self.inner.connections_limit.available_permits()
}

/// Sync events with other relay(s).
#[inline]
pub async fn sync_with<'a, I, U>(
Expand Down
Loading