miraland_program/sysvar/
last_restart_slot.rs

1//! Information about the last restart slot (hard fork).
2//!
3//! The _last restart sysvar_ provides access to the last restart slot kept in the
4//! bank fork for the slot on the fork that executes the current transaction.
5//! In case there was no fork it returns _0_.
6//!
7//! [`LastRestartSlot`] implements [`Sysvar::get`] and can be loaded efficiently without
8//! passing the sysvar account ID to the program.
9//!
10//! See also the Miraland [SIMD proposal][simd].
11//!
12//! [simd]: https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0047-syscall-and-sysvar-for-last-restart-slot.md
13//!
14//! # Examples
15//!
16//! Accessing via on-chain program directly:
17//!
18//! ```no_run
19//! # use miraland_program::{
20//! #    account_info::{AccountInfo, next_account_info},
21//! #    entrypoint::ProgramResult,
22//! #    msg,
23//! #    pubkey::Pubkey,
24//! #    sysvar::Sysvar,
25//! #    last_restart_slot::LastRestartSlot,
26//! # };
27//!
28//! fn process_instruction(
29//!     program_id: &Pubkey,
30//!     accounts: &[AccountInfo],
31//!     instruction_data: &[u8],
32//! ) -> ProgramResult {
33//!
34//!     let last_restart_slot = LastRestartSlot::get();
35//!     msg!("last restart slot: {:?}", last_restart_slot);
36//!
37//!     Ok(())
38//! }
39//! ```
40//!
41
42pub use crate::last_restart_slot::LastRestartSlot;
43use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar};
44
45crate::declare_sysvar_id!(
46    "SysvarLastRestartS1ot1111111111111111111111",
47    LastRestartSlot
48);
49
50impl Sysvar for LastRestartSlot {
51    impl_sysvar_get!(sol_get_last_restart_slot);
52}