Skip to content

Commit

Permalink
review(sami): free rx end out of the Arc
Browse files Browse the repository at this point in the history
and arc the entire controller channel instead
  • Loading branch information
mariocynicys committed Dec 25, 2024
1 parent 6eb6fc3 commit 8ae149b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mm2src/coins/eth/web3_transport/websocket_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ pub struct WebsocketTransport {
node: WebsocketTransportNode,
event_handlers: Vec<RpcTransportEventHandlerShared>,
pub(crate) proxy_sign_keypair: Option<Keypair>,
controller_channel: ControllerChannel,
controller_channel: Arc<ControllerChannel>,
connection_guard: Arc<AsyncMutex<()>>,
}

#[derive(Clone, Debug)]
#[derive(Debug)]
struct ControllerChannel {
tx: UnboundedSender<ControllerMessage>,
rx: Arc<AsyncMutex<UnboundedReceiver<ControllerMessage>>>,
rx: AsyncMutex<UnboundedReceiver<ControllerMessage>>,
}

enum ControllerMessage {
Expand Down Expand Up @@ -86,10 +86,10 @@ impl WebsocketTransport {
node,
event_handlers,
request_id: Arc::new(AtomicUsize::new(1)),
controller_channel: ControllerChannel {
controller_channel: Arc::new(ControllerChannel {
tx: req_tx,
rx: Arc::new(AsyncMutex::new(req_rx)),
},
rx: AsyncMutex::new(req_rx),
}),
connection_guard: Arc::new(AsyncMutex::new(())),
proxy_sign_keypair: None,
last_request_failed: Arc::new(AtomicBool::new(false)),
Expand Down Expand Up @@ -356,7 +356,6 @@ async fn send_request(
serialized_request = serde_json::to_string(&wrapper)?;
}


let (notification_sender, notification_receiver) = oneshot::channel::<Vec<u8>>();

event_handlers.on_outgoing_request(&request_bytes);
Expand Down

0 comments on commit 8ae149b

Please sign in to comment.