From ddd8e2d68bed2bd9efb8379a345bd99eaebd3795 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Tue, 19 Mar 2019 10:41:42 +0200 Subject: refresh_period = ... -> refresh_sec = ... --- src/config.rs | 6 +++--- src/main.rs | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/config.rs b/src/config.rs index cd874da..2effacb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,8 +27,8 @@ pub struct PeerConfig { #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] pub struct UpdateConfig { // Number of seconds between regular updates. - #[serde(default = "default_refresh")] - pub refresh_period: u32, + #[serde(default = "default_refresh_sec")] + pub refresh_sec: u32, } #[serde(deny_unknown_fields)] @@ -64,6 +64,6 @@ fn default_max_keepalive() -> u32 { 0 } -fn default_refresh() -> u32 { +fn default_refresh_sec() -> u32 { 1200 } diff --git a/src/main.rs b/src/main.rs index d556064..14018e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,16 +53,12 @@ impl Device { }) } - fn refresh_period(&self) -> Duration { - Duration::from_secs(u64::from(self.update_config.refresh_period)) - } - fn make_config( &self, public_key: &str, ts: SystemTime, ) -> (wg::Config, Vec, SystemTime) { - let mut t_cfg = ts + self.refresh_period(); + let mut t_cfg = ts + Duration::from_secs(1 << 30); let mut sources: Vec<(&Source, &proto::SourceConfig)> = vec![]; for src in self.sources.iter() { if let Some(ref data) = src.data { @@ -100,7 +96,7 @@ impl Device { } pub fn update(&mut self) -> io::Result { - let refresh = self.refresh_period(); + let refresh = Duration::from_secs(u64::from(self.update_config.refresh_sec)); let mut now = Instant::now(); let mut t_refresh = now + refresh; -- cgit