* Remove unused PohServiceConfig::Step * Clarify variable name * Poh::hash() now takes an iteration counter * man -> max * Inline functions with single call site * Move PohServiceConfig into GenesisBlock * Add plumbing to enable real PoH on testnets * Batch hashes to improve PoH hash rate * Ensure a constant hashes_per_tick * Remove PohEntry mixin field * Poh/PohEntry no longer maintains tick_height * Ensure a constant hashes_per_tick * ci/localnet-sanity.sh: Use real PoH * Rework Poh/PohService to keep PohRecorder unlocked as much as possible while hashing
30 lines
846 B
Rust
30 lines
846 B
Rust
use crate::timing::DEFAULT_NUM_TICKS_PER_SECOND;
|
|
use std::time::Duration;
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub struct PohConfig {
|
|
/// The target tick rate of the cluster.
|
|
pub target_tick_duration: Duration,
|
|
|
|
/// How many hashes to roll before emitting the next tick entry.
|
|
/// None enables "Low power mode", which implies:
|
|
/// * sleep for `target_tick_duration` instead of hashing
|
|
/// * the number of hashes per tick will be variable
|
|
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,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for PohConfig {
|
|
fn default() -> Self {
|
|
Self::new_sleep(Duration::from_millis(1000 / DEFAULT_NUM_TICKS_PER_SECOND))
|
|
}
|
|
}
|