From 6d033264e80025e09d9376239157ea01a7d2b43e Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 18 Oct 2021 10:46:48 +1100 Subject: [PATCH] Fetch announcement in case it is not present but requested This will make sure that if a user retries an operation, the announcement is there. --- daemon/src/oracle.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/daemon/src/oracle.rs b/daemon/src/oracle.rs index 153cf8c..3c5f63b 100644 --- a/daemon/src/oracle.rs +++ b/daemon/src/oracle.rs @@ -224,13 +224,20 @@ impl xtra::Handler for Actor { msg: GetAnnouncement, _ctx: &mut xtra::Context, ) -> Option { - self.announcements - .get_key_value(&msg.0) - .map(|(id, (time, nonce_pks))| Announcement { - id: *id, - expected_outcome_time: *time, - nonce_pks: nonce_pks.clone(), - }) + let announcement = + self.announcements + .get_key_value(&msg.0) + .map(|(id, (time, nonce_pks))| Announcement { + id: *id, + expected_outcome_time: *time, + nonce_pks: nonce_pks.clone(), + }); + + if announcement.is_none() { + self.pending_announcements.insert(msg.0); + } + + announcement } }