Browse Source

Use spawn_fallible inside maker_inc_connections to log errors

Preparation for removing log_error! macro from this actor.
feature/actor-custom-derive
Mariusz Klochowicz 3 years ago
parent
commit
ad4c2720bd
No known key found for this signature in database GPG Key ID: 470C865699C8D4D
  1. 44
      daemon/src/maker_cfd.rs

44
daemon/src/maker_cfd.rs

@ -8,6 +8,7 @@ use crate::model::cfd::{
};
use crate::model::{TakerId, Usd};
use crate::monitor::MonitorParams;
use crate::tokio_ext::spawn_fallible;
use crate::wallet::Wallet;
use crate::{log_error, maker_inc_connections, monitor, oracle, setup_contract, wire};
use anyhow::{Context as _, Result};
@ -574,12 +575,18 @@ where
// Use `.send` here to ensure we only continue once the message has been sent
// Nothing done after this call should be able to fail, otherwise we notified the taker, but
// might not transition to `Active` ourselves!
self.takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyOrderAccepted { id: order_id },
})
.await?;
spawn_fallible::<_, anyhow::Error>({
let takers = self.takers.clone();
async move {
takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyOrderAccepted { id: order_id },
})
.await?;
Ok(())
}
});
// 5. Spawn away the contract setup
let (sender, receiver) = mpsc::unbounded();
@ -751,15 +758,22 @@ where
.await?
.with_context(|| format!("Announcement {} not found", oracle_event_id))?;
self.takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyRollOverAccepted {
id: proposal.order_id,
oracle_event_id,
},
})
.await?;
spawn_fallible::<_, anyhow::Error>({
let takers = self.takers.clone();
let order_id = proposal.order_id;
async move {
takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyRollOverAccepted {
id: order_id,
oracle_event_id,
},
})
.await?;
Ok(())
}
});
self.oracle_actor
.do_send_async(oracle::MonitorAttestation {

Loading…
Cancel
Save