From 77a68942df789a0d972e12a2ee35cc506f15f643 Mon Sep 17 00:00:00 2001 From: Luther Blissett Date: Mon, 26 Sep 2022 13:09:00 +0200 Subject: [PATCH] cargo fmt --- example/lead.rs | 6 ++---- src/util/clock.rs | 53 +++++++++++++++++------------------------------ 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/example/lead.rs b/example/lead.rs index 18ea0433e..98535e366 100644 --- a/example/lead.rs +++ b/example/lead.rs @@ -1,8 +1,6 @@ use futures::executor::block_on; -use halo2_proofs::{dev::MockProver}; -use pasta_curves::{ - pallas, -}; +use halo2_proofs::dev::MockProver; +use pasta_curves::pallas; use url::Url; use darkfi::{ diff --git a/src/util/clock.rs b/src/util/clock.rs index c70a510f1..623bd500f 100644 --- a/src/util/clock.rs +++ b/src/util/clock.rs @@ -1,7 +1,7 @@ -use std::{thread, time::Duration}; -use log::debug; -use url::Url; use crate::{util::time::Timestamp, Result}; +use log::debug; +use std::{thread, time::Duration}; +use url::Url; pub enum Ticks { GENESIS { e: u64, sl: u64 }, //genesis epoch @@ -67,7 +67,7 @@ impl Clock { } /// return absolute tick to genesis, and relative tick index in the slot. - async fn tick_time(&self) -> (u64, u64,u64) { + async fn tick_time(&self) -> (u64, u64, u64) { let time = self.time_to_genesis().await.0 as u64; let tick_abs: u64 = time / self.tick_len; let tick_rel: u64 = time % self.tick_len; @@ -118,13 +118,9 @@ impl Clock { let e = self.epoch_abs().await; let sl = self.slot_relative().await; if self.ticking().await { - debug!("e/e`: {}/{} sl/sl`: {}/{}, BB_E/BB_SL: {}/{}", - e, - self.e, - sl, - self.sl, - BB_E, - BB_SL + debug!( + "e/e`: {}/{} sl/sl`: {}/{}, BB_E/BB_SL: {}/{}", + e, self.e, sl, self.sl, BB_E, BB_SL ); if e == self.e && e == BB_E && self.sl == BB_SL { self.sl = sl + 1; // 0 @@ -158,29 +154,23 @@ impl Clock { #[cfg(test)] mod tests { - use std::{thread, time::Duration}; - use crate::util::clock::{Clock,Ticks}; + use crate::util::{ + clock::{Clock, Ticks}, + time, + }; use futures::executor::block_on; - use crate::util::time; + use std::{thread, time::Duration}; #[test] fn clock_works() { - let clock = Clock::new(Some(9), - Some(9), - Some(9), - vec![] - ); + let clock = Clock::new(Some(9), Some(9), Some(9), vec![]); //block th for 3 secs thread::sleep(Duration::from_millis(1000)); let ttg = block_on(clock.time_to_genesis()).0; - assert!(ttg>=1 && ttg<2); + assert!(ttg >= 1 && ttg < 2); } fn clock_ticking() { - let clock = Clock::new(Some(9), - Some(9), - Some(9), - vec![] - ); + let clock = Clock::new(Some(9), Some(9), Some(9), vec![]); //block th for 3 secs thread::sleep(Duration::from_millis(1000)); assert!(block_on(clock.ticking())); @@ -189,17 +179,12 @@ mod tests { } fn clock_ticks() { - let mut clock = Clock::new(Some(9), - Some(9), - Some(9), - vec![] - ); + let mut clock = Clock::new(Some(9), Some(9), Some(9), vec![]); // - let tick : Ticks = block_on(clock.ticks()); - assert_eq!(matches!(tick, Ticks::GENESIS{e:0,sl:0}), true); + let tick: Ticks = block_on(clock.ticks()); + assert_eq!(matches!(tick, Ticks::GENESIS { e: 0, sl: 0 }), true); thread::sleep(Duration::from_millis(3000)); - let tock : Ticks = block_on(clock.ticks()); + let tock: Ticks = block_on(clock.ticks()); assert_eq!(matches!(tock, Ticks::TOCKS), true); - } }