Expand description
Information about epoch duration.
The epoch schedule sysvar provides access to the EpochSchedule type,
which includes the number of slots per epoch, timing of leader schedule
selection, and information about epoch warm-up time.
EpochSchedule implements Sysvar::get and can be loaded efficiently without
passing the sysvar account ID to the program.
See also the Solana documentation on the epoch schedule sysvar.
§Examples
Accessing via on-chain program directly:
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
let epoch_schedule = EpochSchedule::get()?;
msg!("epoch_schedule: {:#?}", epoch_schedule);
Ok(())
}Accessing via on-chain program’s account parameters:
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let epoch_schedule_account_info = next_account_info(account_info_iter)?;
assert!(epoch_schedule::check_id(epoch_schedule_account_info.key));
let epoch_schedule = EpochSchedule::from_account_info(epoch_schedule_account_info)?;
msg!("epoch_schedule: {:#?}", epoch_schedule);
Ok(())
}Accessing via the RPC client:
fn print_sysvar_epoch_schedule(client: &RpcClient) -> Result<()> {
let epoch_schedule = client.get_account(&epoch_schedule::ID)?;
let data: EpochSchedule = bincode::deserialize(&epoch_schedule.data)?;
Ok(())
}Re-exports§
pub use crate::epoch_schedule::EpochSchedule;
Constants§
- The const program ID.
Functions§
- Returns
trueif given pubkey is the program ID. - Returns the program ID.