Centralize decentralized timing constants
This commit is contained in:
@ -2,6 +2,13 @@
|
||||
use std::time::Duration;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
pub const NUM_TICKS_PER_SECOND: usize = 10;
|
||||
|
||||
// At 10 ticks/s, 8 ticks per slot implies that leader rotation and voting will happen
|
||||
// every 800 ms. A fast voting cadence ensures faster finality and convergence
|
||||
pub const DEFAULT_TICKS_PER_SLOT: u64 = 8;
|
||||
pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 64;
|
||||
|
||||
pub fn duration_as_us(d: &Duration) -> u64 {
|
||||
(d.as_secs() * 1000 * 1000) + (u64::from(d.subsec_nanos()) / 1_000)
|
||||
}
|
||||
|
Reference in New Issue
Block a user