From 07ebb086069e639f3d99c84a98276586250e6ba7 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 18 Nov 2021 17:03:27 +1100 Subject: [PATCH] Transition uses of `do_send` to `send` `do_send` on `MessageChannel` suffers from the same problems as `Address#do_send` and `Address#do_send_async`. Our uses only send messages that never fail so we don't need to adjust anything. --- daemon/src/fan_out.rs | 9 ++++----- daemon/src/taker_cfd.rs | 18 +++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/daemon/src/fan_out.rs b/daemon/src/fan_out.rs index b6834d2..c2cfa16 100644 --- a/daemon/src/fan_out.rs +++ b/daemon/src/fan_out.rs @@ -22,11 +22,10 @@ where { async fn handle(&mut self, message: M, _: &mut xtra::Context) { for receiver in &self.receivers { - // Not sure why here is no `do_send_async` ... - if receiver.do_send(message.clone()).is_err() { - tracing::error!( - "Fan out actor was unable to send to other actor - we should never see this." - ) + if receiver.send(message.clone()).await.is_err() { + // Should ideally remove from list but that is unnecessarily hard with Rust + // iterators + tracing::error!("Actor disconnected, cannot send message"); } } } diff --git a/daemon/src/taker_cfd.rs b/daemon/src/taker_cfd.rs index 92efb93..f6b3f86 100644 --- a/daemon/src/taker_cfd.rs +++ b/daemon/src/taker_cfd.rs @@ -167,7 +167,8 @@ impl Actor { self.order_feed_actor_inbox.send(None)?; self.send_to_maker - .do_send(wire::TakerToMaker::TakeOrder { order_id, quantity })?; + .send(wire::TakerToMaker::TakeOrder { order_id, quantity }) + .await?; Ok(()) } @@ -221,13 +222,14 @@ where self.send_pending_update_proposals()?; self.send_to_maker - .do_send(wire::TakerToMaker::ProposeSettlement { + .send(wire::TakerToMaker::ProposeSettlement { order_id: proposal.order_id, timestamp: proposal.timestamp, taker: proposal.taker, maker: proposal.maker, price: proposal.price, - })?; + }) + .await?; Ok(()) } @@ -381,10 +383,11 @@ where self.send_pending_update_proposals()?; self.send_to_maker - .do_send(wire::TakerToMaker::ProposeRollOver { + .send(wire::TakerToMaker::ProposeRollOver { order_id: proposal.order_id, timestamp: proposal.timestamp, - })?; + }) + .await?; Ok(()) } } @@ -667,10 +670,11 @@ where let (tx, sig_taker) = dlc.close_transaction(proposal)?; self.send_to_maker - .do_send(wire::TakerToMaker::InitiateSettlement { + .send(wire::TakerToMaker::InitiateSettlement { order_id, sig_taker, - })?; + }) + .await?; cfd.handle(CfdStateChangeEvent::ProposalSigned( CollaborativeSettlement::new(