rust-sdk: enable reply-SURBs by default (#2874)

* rust-sdk: enable SURBs by default

* changelog: update

* rustfmt
This commit is contained in:
Jon Häggblad
2023-01-19 15:21:02 +01:00
committed by GitHub
parent c6a5e08188
commit a980d6f804
4 changed files with 27 additions and 6 deletions
+2
View File
@@ -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)
+1 -1
View File
@@ -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;
@@ -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;
}
+17 -2
View File
@@ -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<u8>) {
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<u8>) {
let lane = TransmissionLane::General;
let recipient = Recipient::try_from_base58_string(address).unwrap();
let input_msg = InputMessage::new_regular(recipient, message, lane);