Skip to content

Commit 0d1b841

Browse files
committed
relay-pool: change RelayPool::batch_msg signature
Take a slice instead of a vector in `RelayPool::batch_msg` and `Client::batch_msg`. Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 37399fe commit 0d1b841

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

crates/nostr-relay-pool/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
### Breaking changes
2929

3030
- Change `Relay::send_msg` and `Relay::batch_msg` signatures (https://github.com/rust-nostr/nostr/pull/1124)
31+
- Change `RelayPool::batch_msg` signature (https://github.com/rust-nostr/nostr/pull/1124)
3132

3233
## v0.44.0 - 2025/11/06
3334

crates/nostr-relay-pool/src/pool/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl RelayPool {
659659
U: TryIntoUrl,
660660
Error: From<<U as TryIntoUrl>::Err>,
661661
{
662-
self.batch_msg_to(urls, vec![msg]).await
662+
self.batch_msg_to(urls, &[msg]).await
663663
}
664664

665665
/// Send multiple client messages at once to specific relays
@@ -668,7 +668,7 @@ impl RelayPool {
668668
pub async fn batch_msg_to<I, U>(
669669
&self,
670670
urls: I,
671-
msgs: Vec<ClientMessage<'_>>,
671+
msgs: &[ClientMessage<'_>],
672672
) -> Result<Output<()>, Error>
673673
where
674674
I: IntoIterator<Item = U>,
@@ -713,7 +713,7 @@ impl RelayPool {
713713
for url in set.into_iter() {
714714
let relay: &Relay = self.internal_relay(&relays, &url)?;
715715
urls.push(url);
716-
futures.push(relay.batch_msg(msgs.clone()));
716+
futures.push(relay.batch_msg(msgs));
717717
}
718718

719719
// Join futures

crates/nostr-relay-pool/src/relay/inner.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ impl RelayChannels {
8686

8787
fn send_client_msgs(
8888
&self,
89-
msgs: Vec<ClientMessage>,
89+
msgs: &[ClientMessage],
9090
confirmation: Option<oneshot::Sender<()>>,
9191
) -> Result<(), Error> {
9292
// Serialize messages to JSON
93-
let msgs: Vec<ClientMessageJson> = msgs.into_iter().map(|msg| msg.as_json()).collect();
93+
let msgs: Vec<ClientMessageJson> = msgs.iter().map(|msg| msg.as_json()).collect();
9494

9595
// Build request
9696
let req: SendMessageRequest = SendMessageRequest { msgs, confirmation };
@@ -1325,10 +1325,10 @@ impl InnerRelay {
13251325

13261326
#[inline]
13271327
pub async fn send_msg(&self, msg: ClientMessage<'_>) -> Result<(), Error> {
1328-
self.batch_msg(vec![msg]).await
1328+
self.batch_msg(&[msg]).await
13291329
}
13301330

1331-
pub async fn batch_msg(&self, msgs: Vec<ClientMessage<'_>>) -> Result<(), Error> {
1331+
pub async fn batch_msg(&self, msgs: &[ClientMessage<'_>]) -> Result<(), Error> {
13321332
// Check if relay is operational
13331333
self.ensure_operational()?;
13341334

crates/nostr-relay-pool/src/relay/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl Relay {
411411

412412
/// Send multiple [`ClientMessage`] at once
413413
#[inline]
414-
pub async fn batch_msg(&self, msgs: Vec<ClientMessage<'_>>) -> Result<(), Error> {
414+
pub async fn batch_msg(&self, msgs: &[ClientMessage<'_>]) -> Result<(), Error> {
415415
self.inner.batch_msg(msgs).await
416416
}
417417

crates/nostr-sdk/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
2424
-->
2525

26+
## Unreleased
27+
28+
### Breaking changes
29+
30+
- Change `Client::batch_msg` signature (https://github.com/rust-nostr/nostr/pull/1124)
31+
2632
## v0.44.0 - 2025/11/06
2733

2834
### Breaking changes

crates/nostr-sdk/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ impl Client {
935935
pub async fn batch_msg_to<I, U>(
936936
&self,
937937
urls: I,
938-
msgs: Vec<ClientMessage<'_>>,
938+
msgs: &[ClientMessage<'_>],
939939
) -> Result<Output<()>, Error>
940940
where
941941
I: IntoIterator<Item = U>,

0 commit comments

Comments
 (0)