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