Skip to content

Commit 80033cb

Browse files
committed
change period to periodicity
1 parent ac13c0c commit 80033cb

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The purpose of this changelog is to document new features and breaking changes t
77
- Add JSON <-> Scheme interface
88
- Separate crypto primitives into separate namespace
99
- Add unix time primitive
10+
- Use explicit period instead of periodicity
1011

1112
--- v1.0.4 (2025.09.14) ---
1213

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ pub struct Config {
3030
#[arg(
3131
short = 'c',
3232
long,
33-
default_value_t = 0,
34-
help = "Power of two determining the period of the step query"
33+
default_value_t = 0.0,
34+
help = "Number of seconds between each step inquiry"
3535
)]
36-
pub periodicity: i32,
36+
pub period: f64,
3737
}
3838

3939
impl Config {

src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,19 @@ async fn main() {
117117
rocket_config.address = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
118118
rocket_config.limits = Limits::new().limit("string", 1_i32.mebibytes());
119119

120-
let period = 2_f64.powi(config.periodicity);
121-
122120
if config.step != "" {
123121
tokio::spawn(async move {
124122
let mut step = 0;
125123
let start = ((SystemTime::now()
126124
.duration_since(UNIX_EPOCH)
127125
.expect("Failed to get system time")
128126
.as_micros() as f64
129-
/ (period * MICRO))
127+
/ (config.period * MICRO))
130128
.ceil()
131-
* (period * MICRO)) as u128;
129+
* (config.period * MICRO)) as u128;
132130

133131
loop {
134-
let until = start + step * (period * MICRO) as u128;
132+
let until = start + step * (config.period * MICRO) as u128;
135133
let now = SystemTime::now()
136134
.duration_since(UNIX_EPOCH)
137135
.expect("Failed to get system time")

0 commit comments

Comments
 (0)