From fd33589326d41cba7166239289dd451cfa0cb61b Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 4 Feb 2020 15:14:17 +0000 Subject: [PATCH] Using sending delay from config for the presence notifier --- mixnode/src/node/presence.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mixnode/src/node/presence.rs b/mixnode/src/node/presence.rs index d97e4ea05d..55d1c10df2 100644 --- a/mixnode/src/node/presence.rs +++ b/mixnode/src/node/presence.rs @@ -3,11 +3,13 @@ use directory_client::presence::mixnodes::MixNodePresence; use directory_client::requests::presence_mixnodes_post::PresenceMixNodesPoster; use directory_client::DirectoryClient; use log::{debug, error}; +use std::time; use std::time::Duration; pub struct Notifier { pub net_client: directory_client::Client, presence: MixNodePresence, + sending_delay: time::Duration, } pub struct NotifierConfig { @@ -15,6 +17,7 @@ pub struct NotifierConfig { announce_host: String, pub_key_string: String, layer: u64, + sending_delay: time::Duration, } impl NotifierConfig { @@ -23,12 +26,14 @@ impl NotifierConfig { announce_host: String, pub_key_string: String, layer: u64, + sending_delay: time::Duration, ) -> Self { NotifierConfig { directory_server, announce_host, pub_key_string, layer, + sending_delay, } } } @@ -49,6 +54,7 @@ impl Notifier { Notifier { net_client, presence, + sending_delay: config.sending_delay, } } @@ -60,11 +66,9 @@ impl Notifier { } pub async fn run(self) { - let delay_duration = Duration::from_secs(5); - loop { self.notify(); - tokio::time::delay_for(delay_duration).await; + tokio::time::delay_for(self.sending_delay).await; } } }