Browse Source
Transition to `SetupFailed` if the conract setup failed
Otherwise, the user does not get feedback until restarting the application.
fix/sql-oddness
Daniel Karzel
3 years ago
No known key found for this signature in database
GPG Key ID: 30C3FC2E438ADB6E
2 changed files with
32 additions and
6 deletions
-
daemon/src/maker_cfd.rs
-
daemon/src/taker_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(), |
|
|
|
|
|
@ -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(), |
|
|
|