solana_sdk/
poh_config.rs

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    /// The target tick rate of the cluster.
9    pub target_tick_duration: Duration,
10
11    /// The target total tick count to be produced; used for testing only
12    pub target_tick_count: Option<u64>,
13
14    /// How many hashes to roll before emitting the next tick entry.
15    /// None enables "Low power mode", which implies:
16    /// * sleep for `target_tick_duration` instead of hashing
17    /// * the number of hashes per tick will be variable
18    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}