Browse Source

Merge #487

487: Transition to `SetupFailed` if the conract setup failed r=da-kami a=da-kami

Otherwise, the user does not get feedback until restarting the application.

Note: Given what is described in #364 this will be solved in a more complete way. This PR more of a workaround to get user feedback that the contract setup failed. At the moment we don't know until restarting the application which sucks.

Co-authored-by: Daniel Karzel <daniel@comit.network>
fix/sql-oddness
bors[bot] 3 years ago
committed by GitHub
parent
commit
02a8c7ce03
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      daemon/src/maker_cfd.rs
  2. 20
      daemon/src/taker_cfd.rs

18
daemon/src/maker_cfd.rs

@ -679,11 +679,23 @@ where
) -> Result<()> {
self.setup_state = SetupState::None;
let dlc = dlc.context("Failed to setup contract with taker")?;
let mut conn = self.db.acquire().await?;
let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?;
let dlc = match dlc {
Ok(dlc) => dlc,
Err(e) => {
cfd.state = CfdState::SetupFailed {
common: CfdStateCommon::default(),
info: e.to_string(),
};
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
return Err(e);
}
};
cfd.state = CfdState::PendingOpen {
common: CfdStateCommon::default(),
dlc: dlc.clone(),

20
daemon/src/taker_cfd.rs

@ -395,12 +395,26 @@ where
dlc: Result<Dlc>,
) -> Result<()> {
self.setup_state = SetupState::None;
let dlc = dlc.context("Failed to setup contract with maker")?;
tracing::info!("Setup complete, publishing on chain now");
let mut conn = self.db.acquire().await?;
let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?;
let dlc = match dlc {
Ok(dlc) => dlc,
Err(e) => {
cfd.state = CfdState::SetupFailed {
common: CfdStateCommon::default(),
info: e.to_string(),
};
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
return Err(e);
}
};
tracing::info!("Setup complete, publishing on chain now");
cfd.state = CfdState::PendingOpen {
common: CfdStateCommon::default(),
dlc: dlc.clone(),

Loading…
Cancel
Save