diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f6bd15ea8..9a78613a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,11 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// - dkg rerun from scratch and dkg-specific epochs ([#2839]) - nym-sdk: add support for surb storage ([#2870]) +- nym-sdk: enable reply-SURBs by default ([#2874]) [#2839]: https://github.com/nymtech/nym/pull/2839 [#2870]: https://github.com/nymtech/nym/pull/2870 +[#2874]: https://github.com/nymtech/nym/pull/2874 ## [v1.1.6] (2023-01-17) diff --git a/sdk/rust/nym-sdk/examples/simple.rs b/sdk/rust/nym-sdk/examples/simple.rs index 99393c7a4c..d11d4c85a6 100644 --- a/sdk/rust/nym-sdk/examples/simple.rs +++ b/sdk/rust/nym-sdk/examples/simple.rs @@ -16,7 +16,7 @@ async fn main() { .send_str(&our_address.to_string(), "hello there") .await; - println!("Waiting for message"); + println!("Waiting for message (ctrl-c to exit)"); client .on_messages(|msg| println!("Received: {}", String::from_utf8_lossy(&msg.message))) .await; diff --git a/sdk/rust/nym-sdk/examples/simple_but_manually_connect.rs b/sdk/rust/nym-sdk/examples/simple_but_manually_connect.rs index 96b79a3c24..453ae795bd 100644 --- a/sdk/rust/nym-sdk/examples/simple_but_manually_connect.rs +++ b/sdk/rust/nym-sdk/examples/simple_but_manually_connect.rs @@ -22,7 +22,11 @@ async fn main() { .await; println!("Waiting for message"); - client - .on_messages(|msg| println!("Received: {}", String::from_utf8_lossy(&msg.message))) - .await; + if let Some(received) = client.wait_for_messages().await { + for r in received { + println!("Received: {}", String::from_utf8_lossy(&r.message)); + } + } + + client.disconnect().await; } diff --git a/sdk/rust/nym-sdk/src/mixnet/client.rs b/sdk/rust/nym-sdk/src/mixnet/client.rs index c9088793eb..9a7df7ee96 100644 --- a/sdk/rust/nym-sdk/src/mixnet/client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/client.rs @@ -346,15 +346,30 @@ impl MixnetClient { /// Sends stringy data to the supplied Nym address pub async fn send_str(&self, address: &str, message: &str) { - log::debug!("send_str"); + let message_bytes = message.to_string().into_bytes(); + self.send_bytes(address, message_bytes).await; + } + + /// Sends stringy data to the supplied Nym address, and skip sending reply-SURBs + pub async fn send_str_direct(&self, address: &str, message: &str) { let message_bytes = message.to_string().into_bytes(); self.send_bytes(address, message_bytes).await; } /// Sends bytes to the supplied Nym address pub async fn send_bytes(&self, address: &str, message: Vec) { - log::debug!("send_bytes"); + let lane = TransmissionLane::General; + let recipient = Recipient::try_from_base58_string(address).unwrap(); + let input_msg = InputMessage::new_anonymous(recipient, message, 20, lane); + self.client_input + .input_sender + .send(input_msg) + .await + .unwrap(); + } + /// Sends bytes to the supplied Nym address, and skip sending reply-SURBs + pub async fn send_bytes_direct(&self, address: &str, message: Vec) { let lane = TransmissionLane::General; let recipient = Recipient::try_from_base58_string(address).unwrap(); let input_msg = InputMessage::new_regular(recipient, message, lane);