forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0276c07
commit 7be4788
Showing
9 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[package] | ||
name = "solana-poh-config" | ||
description = "Definitions of Solana's proof of history." | ||
documentation = "https://docs.rs/solana-poh-config" | ||
version = { workspace = true } | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
all-features = true | ||
rustdoc-args = ["--cfg=docsrs"] | ||
|
||
[dependencies] | ||
serde = { workspace = true, optional = true } | ||
serde_derive = { workspace = true, optional = true } | ||
solana-frozen-abi = { workspace = true, optional = true, features = [ | ||
"frozen-abi", | ||
] } | ||
solana-frozen-abi-macro = { workspace = true, optional = true, features = [ | ||
"frozen-abi", | ||
] } | ||
|
||
[dev-dependencies] | ||
solana-clock = { workspace = true } | ||
static_assertions = { workspace = true } | ||
|
||
[features] | ||
frozen-abi = [ | ||
"dep:solana-frozen-abi", | ||
"dep:solana-frozen-abi-macro", | ||
] | ||
serde = ["dep:serde", "dep:serde_derive"] | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! Definitions of Solana's proof of history. | ||
#![cfg_attr(docsrs, feature(doc_auto_cfg))] | ||
#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] | ||
|
||
use std::time::Duration; | ||
|
||
// inlined to avoid solana-clock dep | ||
const DEFAULT_TICKS_PER_SECOND: u64 = 160; | ||
#[cfg(test)] | ||
static_assertions::const_assert_eq!( | ||
DEFAULT_TICKS_PER_SECOND, | ||
solana_clock::DEFAULT_TICKS_PER_SECOND | ||
); | ||
|
||
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] | ||
#[cfg_attr( | ||
feature = "serde", | ||
derive(serde_derive::Deserialize, serde_derive::Serialize) | ||
)] | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct PohConfig { | ||
/// The target tick rate of the cluster. | ||
pub target_tick_duration: Duration, | ||
|
||
/// The target total tick count to be produced; used for testing only | ||
pub target_tick_count: Option<u64>, | ||
|
||
/// How many hashes to roll before emitting the next tick entry. | ||
/// None enables "Low power mode", which makes the validator sleep | ||
/// for `target_tick_duration` instead of hashing | ||
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, | ||
} | ||
} | ||
} | ||
|
||
// the !=0 check was previously done by the unchecked_div_by_const macro | ||
#[cfg(test)] | ||
static_assertions::const_assert!(DEFAULT_TICKS_PER_SECOND != 0); | ||
const DEFAULT_SLEEP_MICROS: u64 = (1000 * 1000) / DEFAULT_TICKS_PER_SECOND; | ||
|
||
impl Default for PohConfig { | ||
fn default() -> Self { | ||
Self::new_sleep(Duration::from_micros(DEFAULT_SLEEP_MICROS)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.