1use {
4 crate::{clock::DEFAULT_TICKS_PER_SECOND, unchecked_div_by_const},
5 std::time::Duration,
6};
7
8#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
9#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
10pub struct PohConfig {
11 pub target_tick_duration: Duration,
13
14 pub target_tick_count: Option<u64>,
16
17 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}