#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "sysvar")]
pub mod sysvar;
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
use solana_sdk_macro::CloneZeroed;
pub const DEFAULT_TICKS_PER_SLOT: u64 = 64;
pub const DEFAULT_NS_PER_SLOT_400_MS: u64 = 400_000_000;
pub const DEFAULT_NS_PER_SLOT_350_MS: u64 = 350_000_000;
pub const DEFAULT_NS_PER_SLOT_300_MS: u64 = 300_000_000;
pub const DEFAULT_NS_PER_SLOT_250_MS: u64 = 250_000_000;
pub const DEFAULT_NS_PER_SLOT_200_MS: u64 = 200_000_000;
pub const DEFAULT_NS_PER_SLOT: u64 = DEFAULT_NS_PER_SLOT_300_MS;
pub const DEFAULT_NS_PER_TICK_400_MS: u64 = DEFAULT_NS_PER_SLOT_400_MS / DEFAULT_TICKS_PER_SLOT;
pub const DEFAULT_NS_PER_TICK_350_MS: u64 = DEFAULT_NS_PER_SLOT_350_MS / DEFAULT_TICKS_PER_SLOT;
pub const DEFAULT_NS_PER_TICK_300_MS: u64 = DEFAULT_NS_PER_SLOT_300_MS / DEFAULT_TICKS_PER_SLOT;
pub const DEFAULT_NS_PER_TICK_250_MS: u64 = DEFAULT_NS_PER_SLOT_250_MS / DEFAULT_TICKS_PER_SLOT;
pub const DEFAULT_NS_PER_TICK_200_MS: u64 = DEFAULT_NS_PER_SLOT_200_MS / DEFAULT_TICKS_PER_SLOT;
pub const DEFAULT_NS_PER_TICK: u64 = DEFAULT_NS_PER_TICK_300_MS;
pub const DEFAULT_TICKS_PER_SECOND_400_MS: u64 = 1_000_000_000 / DEFAULT_NS_PER_TICK_400_MS;
pub const DEFAULT_TICKS_PER_SECOND_350_MS: u64 = 1_000_000_000 / DEFAULT_NS_PER_TICK_350_MS;
pub const DEFAULT_TICKS_PER_SECOND_300_MS: u64 = 1_000_000_000 / DEFAULT_NS_PER_TICK_300_MS;
pub const DEFAULT_TICKS_PER_SECOND_250_MS: u64 = 1_000_000_000 / DEFAULT_NS_PER_TICK_250_MS;
pub const DEFAULT_TICKS_PER_SECOND_200_MS: u64 = 1_000_000_000 / DEFAULT_NS_PER_TICK_200_MS;
pub const DEFAULT_TICKS_PER_SECOND: u64 = DEFAULT_TICKS_PER_SECOND_300_MS;
#[cfg(test)]
static_assertions::const_assert_eq!(MS_PER_TICK, 4);
pub const MS_PER_TICK_400_MS: u64 = DEFAULT_NS_PER_TICK_400_MS / 1_000_000;
pub const MS_PER_TICK_350_MS: u64 = DEFAULT_NS_PER_TICK_350_MS / 1_000_000;
pub const MS_PER_TICK_300_MS: u64 = DEFAULT_NS_PER_TICK_300_MS / 1_000_000;
pub const MS_PER_TICK_250_MS: u64 = DEFAULT_NS_PER_TICK_250_MS / 1_000_000;
pub const MS_PER_TICK_200_MS: u64 = DEFAULT_NS_PER_TICK_200_MS / 1_000_000;
pub const MS_PER_TICK: u64 = MS_PER_TICK_300_MS;
pub const DEFAULT_HASHES_PER_SECOND: u64 = 10_000_000;
#[cfg(test)]
static_assertions::const_assert_eq!(DEFAULT_HASHES_PER_TICK, 46_875);
pub const DEFAULT_HASHES_PER_TICK_400_MS: u64 = 62_500;
pub const DEFAULT_HASHES_PER_TICK_350_MS: u64 = 54_687;
pub const DEFAULT_HASHES_PER_TICK_300_MS: u64 = 46_875;
pub const DEFAULT_HASHES_PER_TICK_250_MS: u64 = 39_062;
pub const DEFAULT_HASHES_PER_TICK_200_MS: u64 = 31_250;
pub const DEFAULT_HASHES_PER_TICK: u64 = DEFAULT_HASHES_PER_TICK_300_MS;
pub const DEFAULT_DEV_SLOTS_PER_EPOCH: u64 = 8192;
#[cfg(test)]
static_assertions::const_assert_eq!(SECONDS_PER_DAY, 86_400);
pub const SECONDS_PER_DAY: u64 = 24 * 60 * 60;
#[cfg(test)]
static_assertions::const_assert_eq!(TICKS_PER_DAY, 18_432_000);
pub const TICKS_PER_DAY_400_MS: u64 = SECONDS_PER_DAY * 1_000_000_000 / DEFAULT_NS_PER_TICK_400_MS;
pub const TICKS_PER_DAY_350_MS: u64 = SECONDS_PER_DAY * 1_000_000_000 / DEFAULT_NS_PER_TICK_350_MS;
pub const TICKS_PER_DAY_300_MS: u64 = SECONDS_PER_DAY * 1_000_000_000 / DEFAULT_NS_PER_TICK_300_MS;
pub const TICKS_PER_DAY_250_MS: u64 = SECONDS_PER_DAY * 1_000_000_000 / DEFAULT_NS_PER_TICK_250_MS;
pub const TICKS_PER_DAY_200_MS: u64 = SECONDS_PER_DAY * 1_000_000_000 / DEFAULT_NS_PER_TICK_200_MS;
pub const TICKS_PER_DAY: u64 = TICKS_PER_DAY_300_MS;
pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 432_000;
#[cfg(test)]
static_assertions::const_assert_eq!(DEFAULT_MS_PER_SLOT, 300);
pub const DEFAULT_MS_PER_SLOT_400_MS: u64 = DEFAULT_NS_PER_SLOT_400_MS / 1_000_000;
pub const DEFAULT_MS_PER_SLOT_350_MS: u64 = DEFAULT_NS_PER_SLOT_350_MS / 1_000_000;
pub const DEFAULT_MS_PER_SLOT_300_MS: u64 = DEFAULT_NS_PER_SLOT_300_MS / 1_000_000;
pub const DEFAULT_MS_PER_SLOT_250_MS: u64 = DEFAULT_NS_PER_SLOT_250_MS / 1_000_000;
pub const DEFAULT_MS_PER_SLOT_200_MS: u64 = DEFAULT_NS_PER_SLOT_200_MS / 1_000_000;
pub const DEFAULT_MS_PER_SLOT: u64 = DEFAULT_MS_PER_SLOT_300_MS;
pub const DEFAULT_S_PER_SLOT_400_MS: f64 = DEFAULT_MS_PER_SLOT_400_MS as f64 / 1_000.0;
pub const DEFAULT_S_PER_SLOT_350_MS: f64 = DEFAULT_MS_PER_SLOT_350_MS as f64 / 1_000.0;
pub const DEFAULT_S_PER_SLOT_300_MS: f64 = DEFAULT_MS_PER_SLOT_300_MS as f64 / 1_000.0;
pub const DEFAULT_S_PER_SLOT_250_MS: f64 = DEFAULT_MS_PER_SLOT_250_MS as f64 / 1_000.0;
pub const DEFAULT_S_PER_SLOT_200_MS: f64 = DEFAULT_MS_PER_SLOT_200_MS as f64 / 1_000.0;
pub const DEFAULT_S_PER_SLOT: f64 = DEFAULT_S_PER_SLOT_300_MS;
pub const MAX_HASH_AGE_IN_SECONDS_400_MS: usize = 120;
pub const MAX_HASH_AGE_IN_SECONDS_350_MS: usize = 105;
pub const MAX_HASH_AGE_IN_SECONDS_300_MS: usize = 90;
pub const MAX_HASH_AGE_IN_SECONDS_250_MS: usize = 75;
pub const MAX_HASH_AGE_IN_SECONDS_200_MS: usize = 60;
pub const MAX_HASH_AGE_IN_SECONDS: usize = MAX_HASH_AGE_IN_SECONDS_300_MS;
pub const MAX_RECENT_BLOCKHASHES: usize = 300;
#[cfg(test)]
static_assertions::const_assert_eq!(MAX_PROCESSING_AGE, 150);
pub const MAX_PROCESSING_AGE: usize = MAX_RECENT_BLOCKHASHES / 2;
pub const MAX_TRANSACTION_FORWARDING_DELAY_GPU: usize = 2;
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 6;
pub const FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET: u64 = 2;
pub const HOLD_TRANSACTIONS_SLOT_OFFSET: u64 = 20;
pub type Slot = u64;
pub type BankId = u64;
pub type Epoch = u64;
pub const GENESIS_EPOCH: Epoch = 0;
pub const INITIAL_RENT_EPOCH: Epoch = 0;
pub type SlotIndex = u64;
pub type SlotCount = u64;
pub type UnixTimestamp = i64;
#[repr(C)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "wincode", derive(wincode::SchemaWrite, wincode::SchemaRead))]
#[derive(Debug, CloneZeroed, Default, PartialEq, Eq)]
pub struct Clock {
pub slot: Slot,
pub epoch_start_timestamp: UnixTimestamp,
pub epoch: Epoch,
pub leader_schedule_epoch: Epoch,
pub unix_timestamp: UnixTimestamp,
}
pub const SIZE: usize = size_of::<Clock>();
const _: () = assert!(SIZE == 40);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_size_of() {
assert_eq!(
wincode::serialized_size(&Clock::default()).unwrap() as usize,
SIZE,
);
}
#[test]
fn test_clone() {
let clock = Clock {
slot: 1,
epoch_start_timestamp: 2,
epoch: 3,
leader_schedule_epoch: 4,
unix_timestamp: 5,
};
let cloned_clock = clock.clone();
assert_eq!(cloned_clock, clock);
}
}