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

Loading…
Cancel
Save