Browse Source

Merge #626

626: Ban use of `MessageChannel#do_send` r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
reconnect-to-maker
bors[bot] 3 years ago
committed by GitHub
parent
commit
a2e432c706
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      clippy.toml
  2. 9
      daemon/src/fan_out.rs
  3. 19
      daemon/src/taker_cfd.rs

1
clippy.toml

@ -1,4 +1,5 @@
disallowed-methods = [
"xtra::Address::do_send_async", # discards the return value, possibly swallowing an error
"xtra::Address::do_send", # discards the return value, possibly swallowing an error
"xtra::message_channel::MessageChannel::do_send", # discards the return value, possibly swallowing an error
]

9
daemon/src/fan_out.rs

@ -22,11 +22,10 @@ where
{
async fn handle(&mut self, message: M, _: &mut xtra::Context<Self>) {
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");
}
}
}

19
daemon/src/taker_cfd.rs

@ -167,7 +167,8 @@ impl<O, M, W> Actor<O, M, W> {
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(
@ -740,7 +744,6 @@ where
+ xtra::Handler<wallet::BuildPartyParams>,
{
async fn handle(&mut self, msg: wire::MakerToTaker, ctx: &mut Context<Self>) {
tracing::trace!("message from maker: {:?}", msg);
match msg {
wire::MakerToTaker::Heartbeat => {
unreachable!("Heartbeats should be handled somewhere else")

Loading…
Cancel
Save