Skip to content

Commit 94b8593

Browse files
author
Damon Chen
committed
Back to unbounded_channel
1 parent 532e608 commit 94b8593

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

wallet-connect/src/client/socket.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use thiserror::Error;
1212
use tokio::time::sleep;
1313
use tokio::{
1414
sync::{
15-
mpsc::{channel, Sender},
15+
mpsc::{unbounded_channel, UnboundedSender},
1616
oneshot,
1717
},
1818
task::JoinHandle,
@@ -33,7 +33,7 @@ use eyre::{eyre, Context};
3333
#[derive(Debug)]
3434
pub struct Socket {
3535
/// queue for messages to be sent to the bridge server
36-
sender: Sender<(Option<u64>, Vec<u8>)>,
36+
sender: UnboundedSender<(Option<u64>, Vec<u8>)>,
3737
/// the handle of the task that writes on the websocket connection
3838
_write_handle: JoinHandle<()>,
3939
/// the handle of the task that reads on the websocket connection
@@ -96,11 +96,7 @@ impl Socket {
9696
id: u64,
9797
msg: SocketMessage,
9898
) -> eyre::Result<()> {
99-
if let Err(_e) = self
100-
.sender
101-
.send((Some(id), serde_json::to_vec(&msg)?))
102-
.await
103-
{
99+
if let Err(_e) = self.sender.send((Some(id), serde_json::to_vec(&msg)?)) {
104100
// not to let the requester to wait forever
105101
const ERROR_MSG: &str = "\"Failed to send message to the queue\"";
106102
if let Some((_id, sender)) = context.0.pending_requests.remove(&id) {
@@ -215,7 +211,7 @@ impl Socket {
215211
silent: true,
216212
};
217213
let payload = serde_json::to_vec(&msg)?;
218-
self.sender.send((None, payload)).await?;
214+
self.sender.send((None, payload))?;
219215
Ok(())
220216
}
221217

@@ -225,8 +221,7 @@ impl Socket {
225221
pub async fn connect(url: Url, key: Key, handler: MessageHandler) -> eyre::Result<Self> {
226222
let (mut tx, rx) = connect(url).await?.split();
227223
let context = handler.context.clone();
228-
let (sender, mut receiver) =
229-
channel::<(Option<u64>, Vec<u8>)>(context.0.pending_requests_limit);
224+
let (sender, mut receiver) = unbounded_channel::<(Option<u64>, Vec<u8>)>();
230225
let sender_out = sender.clone();
231226

232227
// a task for reading from the websocket connection, decrypting the data

0 commit comments

Comments
 (0)