solana_program/sysvar/
slot_history.rs

1//! named accounts for synthesized data accounts for bank state, etc.
2//!
3//! this account carries a bitvector of slots present over the past
4//! epoch
5//!
6use crate::sysvar::Sysvar;
7pub use crate::{
8    account_info::AccountInfo, program_error::ProgramError, slot_history::SlotHistory,
9};
10
11crate::declare_sysvar_id!("SysvarS1otHistory11111111111111111111111111", SlotHistory);
12
13impl Sysvar for SlotHistory {
14    // override
15    fn size_of() -> usize {
16        // hard-coded so that we don't have to construct an empty
17        131_097 // golden, update if MAX_ENTRIES changes
18    }
19    fn from_account_info(_account_info: &AccountInfo) -> Result<Self, ProgramError> {
20        // This sysvar is too large to bincode::deserialize in-program
21        Err(ProgramError::UnsupportedSysvar)
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28    #[test]
29    fn test_size_of() {
30        assert_eq!(
31            SlotHistory::size_of(),
32            bincode::serialized_size(&SlotHistory::default()).unwrap() as usize
33        );
34    }
35}