Browse Source

Allow transitions to same state in db

We currently have cases where the CFD might transition to a same state twice when restarting.
Furthermore, we might transition from `Open` to `Open` upon renewal.
Since it is currently unclear if this restriction is really needed we just print a warning in the logs instead of failing.
fix-bad-api-calls
Daniel Karzel 3 years ago
parent
commit
75033a9c32
No known key found for this signature in database GPG Key ID: 30C3FC2E438ADB6E
  1. 6
      daemon/src/db.rs

6
daemon/src/db.rs

@ -170,7 +170,11 @@ pub async fn insert_new_cfd_state_by_order_id(
// make sure that the new state is different than the current one to avoid that we save the same
// state twice
if mem::discriminant(&latest_cfd_state_in_db) == mem::discriminant(&new_state) {
anyhow::bail!("Cannot insert new state {} for cfd with order_id {} because it currently already is in state {}", new_state, order_id, latest_cfd_state_in_db);
tracing::warn!(
"Same state transition for cfd with order_id {}: {}",
order_id,
latest_cfd_state_in_db
);
}
let cfd_state = serde_json::to_string(&new_state)?;

Loading…
Cancel
Save