Module switchboard_solana::program_id::sysvar::epoch_rewards
Expand description
Epoch rewards for current epoch
The epoch rewards sysvar provides access to the EpochRewards
type,
which tracks the progress of epoch rewards distribution. It includes the
- total rewards for the current epoch, in lamports
- rewards for the current epoch distributed so far, in lamports
- distribution completed block height, i.e. distribution of all staking rewards for the current epoch will be completed at this block height
EpochRewards
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 rewards sysvar.
§Examples
Accessing via on-chain program directly:
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
let epoch_rewards = EpochRewards::get()?;
msg!("epoch_rewards: {:#?}", epoch_rewards);
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_rewards_account_info = next_account_info(account_info_iter)?;
assert!(epoch_rewards::check_id(epoch_rewards_account_info.key));
let epoch_rewards = EpochRewards::from_account_info(epoch_rewards_account_info)?;
msg!("epoch_rewards: {:#?}", epoch_rewards);
Ok(())
}
Accessing via the RPC client:
fn print_sysvar_epoch_rewards(client: &RpcClient) -> Result<()> {
let epoch_rewards = client.get_account(&epoch_rewards::ID)?;
let data: EpochRewards = bincode::deserialize(&epoch_rewards.data)?;
Ok(())
}
Structs§
Constants§
- The const program ID.
Functions§
- Returns
true
if given pubkey is the program ID. - Returns the program ID.