Browse Source

Use the original order's term for rolling over

This allows us to avoid the use of the constant in two places which
removes the dependency on the constant from the taker entirely.

The logic here is generally not great - in particular having the taker
anticipate, which announcement it is going to be - but this is the
least invasive way of making the term dynamic.
contact-taker-before-changing-cfd-state
Thomas Eizinger 3 years ago
committed by Philipp Hoenisch
parent
commit
d789732ed7
No known key found for this signature in database GPG Key ID: E5F8E74C672BC666
  1. 2
      daemon/src/maker_cfd.rs
  2. 4
      daemon/src/taker_cfd.rs

2
daemon/src/maker_cfd.rs

@ -751,7 +751,7 @@ where
let dlc = cfd.open_dlc().context("CFD was in wrong state")?;
let oracle_event_id =
oracle::next_announcement_after(time::OffsetDateTime::now_utc() + Order::TERM)?;
oracle::next_announcement_after(time::OffsetDateTime::now_utc() + cfd.order.term)?;
let announcement = self
.oracle_actor
.send(oracle::GetAnnouncement(oracle_event_id))

4
daemon/src/taker_cfd.rs

@ -340,6 +340,8 @@ where
anyhow::bail!("An update for order id {} is already in progress", order_id)
}
let order = load_order_by_id(order_id, &mut self.db.acquire().await?).await?;
let proposal = RollOverProposal {
order_id,
timestamp: SystemTime::now(),
@ -357,7 +359,7 @@ where
// we are likely going to need this one
self.oracle_actor
.send(oracle::FetchAnnouncement(oracle::next_announcement_after(
OffsetDateTime::now_utc() + Order::TERM,
OffsetDateTime::now_utc() + order.term,
)?))
.await?;

Loading…
Cancel
Save