Using sending delay from config for the presence notifier
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user