solana_sdk/
poh_config.rs

1//! Definitions of Solana's proof of history.
2
3use {
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    /// The target tick rate of the cluster.
12    pub target_tick_duration: Duration,
13
14    /// The target total tick count to be produced; used for testing only
15    pub target_tick_count: Option<u64>,
16
17    /// How many hashes to roll before emitting the next tick entry.
18    /// None enables "Low power mode", which makes the validator sleep
19    /// for `target_tick_duration` instead of hashing
20    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}