Browse Source

Stop contract and rollover from the maker if cannot notify the taker

As for now, we were only logging the communication problem and moving on.
contact-taker-before-changing-cfd-state
Mariusz Klochowicz 3 years ago
parent
commit
331c6dedf2
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,7 +8,6 @@ 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};
@ -575,18 +574,12 @@ 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!
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(())
}
});
self.takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyOrderAccepted { id: order_id },
})
.await??;
// 5. Spawn away the contract setup
let (sender, receiver) = mpsc::unbounded();
@ -758,22 +751,15 @@ where
.await?
.with_context(|| format!("Announcement {} not found", oracle_event_id))?;
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.takers
.send(maker_inc_connections::TakerMessage {
taker_id,
command: TakerCommand::NotifyRollOverAccepted {
id: proposal.order_id,
oracle_event_id,
},
})
.await??;
self.oracle_actor
.do_send_async(oracle::MonitorAttestation {

Loading…
Cancel
Save