From 0660e02b1fb63772d1cf64cd86c9f85687388e7a Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Thu, 7 Oct 2021 15:40:12 +1100 Subject: [PATCH] Oracle actor initial state update Block until we are sure that the update was done, because otherwise we might have weird side effects in the UI because there is a dependency on the announcements being available when creating offers. --- daemon/src/maker.rs | 5 ++++- daemon/src/taker.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/src/maker.rs b/daemon/src/maker.rs index 7611b8d..df837e3 100644 --- a/daemon/src/maker.rs +++ b/daemon/src/maker.rs @@ -227,7 +227,7 @@ async fn main() -> Result<()> { update_cfd_feed_sender, maker_inc_connections_address.clone(), monitor_actor_address.clone(), - oracle_actor_address, + oracle_actor_address.clone(), ) .create(None) .spawn_global(); @@ -265,6 +265,9 @@ async fn main() -> Result<()> { cfds, ))); + // use `.send` here to ensure we only continue once the update was processed + oracle_actor_address.send(oracle::Sync).await.unwrap(); + let listener_stream = futures::stream::poll_fn(move |ctx| { let message = match futures::ready!(listener.poll_accept(ctx)) { Ok((stream, address)) => { diff --git a/daemon/src/taker.rs b/daemon/src/taker.rs index f17fa25..0e7358f 100644 --- a/daemon/src/taker.rs +++ b/daemon/src/taker.rs @@ -227,7 +227,7 @@ async fn main() -> Result<()> { update_cfd_feed_sender, send_to_maker, monitor_actor_address.clone(), - oracle_actor_address, + oracle_actor_address.clone(), ) .create(None) .spawn_global(); @@ -264,6 +264,9 @@ async fn main() -> Result<()> { cfds, ))); + // use `.send` here to ensure we only continue once the update was processed + oracle_actor_address.send(oracle::Sync).await.unwrap(); + Ok(rocket.manage(cfd_actor_inbox).manage(cfd_feed_receiver)) }, ))