use {
crate::{clock::DEFAULT_TICKS_PER_SECOND, unchecked_div_by_const},
std::time::Duration,
};
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct PohConfig {
pub target_tick_duration: Duration,
pub target_tick_count: Option<u64>,
pub hashes_per_tick: Option<u64>,
}
impl PohConfig {
pub fn new_sleep(target_tick_duration: Duration) -> Self {
Self {
target_tick_duration,
hashes_per_tick: None,
target_tick_count: None,
}
}
}
impl Default for PohConfig {
fn default() -> Self {
Self::new_sleep(Duration::from_micros(unchecked_div_by_const!(
1000 * 1000,
DEFAULT_TICKS_PER_SECOND
)))
}
}