53 lines
1.5 KiB
Rust
53 lines
1.5 KiB
Rust
//! Information about the last restart slot (hard fork).
|
|
//!
|
|
//! The _last restart sysvar_ provides access to the last restart slot kept in the
|
|
//! bank fork for the slot on the fork that executes the current transaction.
|
|
//! In case there was no fork it returns _0_.
|
|
//!
|
|
//! [`LastRestartSlot`] implements [`Sysvar::get`] and can be loaded efficiently without
|
|
//! passing the sysvar account ID to the program.
|
|
//!
|
|
//! See also the Solana [SIMD proposal][simd].
|
|
//!
|
|
//! [simd]: https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0047-syscall-and-sysvar-for-last-restart-slot.md
|
|
//!
|
|
//! # Examples
|
|
//!
|
|
//! Accessing via on-chain program directly:
|
|
//!
|
|
//! ```no_run
|
|
//! # use solana_program::{
|
|
//! # account_info::{AccountInfo, next_account_info},
|
|
//! # entrypoint::ProgramResult,
|
|
//! # msg,
|
|
//! # pubkey::Pubkey,
|
|
//! # sysvar::Sysvar,
|
|
//! # last_restart_slot::LastRestartSlot,
|
|
//! # };
|
|
//!
|
|
//! fn process_instruction(
|
|
//! program_id: &Pubkey,
|
|
//! accounts: &[AccountInfo],
|
|
//! instruction_data: &[u8],
|
|
//! ) -> ProgramResult {
|
|
//!
|
|
//! let last_restart_slot = LastRestartSlot::get();
|
|
//! msg!("last restart slot: {:?}", last_restart_slot);
|
|
//!
|
|
//! Ok(())
|
|
//! }
|
|
//! ```
|
|
//!
|
|
|
|
pub use crate::last_restart_slot::LastRestartSlot;
|
|
use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar};
|
|
|
|
crate::declare_sysvar_id!(
|
|
"SysvarLastRestartS1ot1111111111111111111111",
|
|
LastRestartSlot
|
|
);
|
|
|
|
impl Sysvar for LastRestartSlot {
|
|
impl_sysvar_get!(sol_get_last_restart_slot);
|
|
}
|