1use {
4 crate::{clock::DEFAULT_TICKS_PER_SECOND, unchecked_div_by_const},
5 std::time::Duration,
6};
7
8#[derive(Serialize, Deserialize, Clone, Debug, AbiExample, Eq, PartialEq)]
9pub struct PohConfig {
10 pub target_tick_duration: Duration,
12
13 pub target_tick_count: Option<u64>,
15
16 pub hashes_per_tick: Option<u64>,
21}
22
23impl PohConfig {
24 pub fn new_sleep(target_tick_duration: Duration) -> Self {
25 Self {
26 target_tick_duration,
27 hashes_per_tick: None,
28 target_tick_count: None,
29 }
30 }
31}
32
33impl Default for PohConfig {
34 fn default() -> Self {
35 Self::new_sleep(Duration::from_micros(unchecked_div_by_const!(
36 1000 * 1000,
37 DEFAULT_TICKS_PER_SECOND
38 )))
39 }
40}