gemachain_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//!
6pub use crate::{
7    account_info::AccountInfo, program_error::ProgramError, slot_history::SlotHistory,
8};
9
10use crate::sysvar::Sysvar;
11
12crate::declare_sysvar_id!("SysvarS1otHistory11111111111111111111111111", SlotHistory);
13
14impl Sysvar for SlotHistory {
15    // override
16    fn size_of() -> usize {
17        // hard-coded so that we don't have to construct an empty
18        131_097 // golden, update if MAX_ENTRIES changes
19    }
20    fn from_account_info(_account_info: &AccountInfo) -> Result<Self, ProgramError> {
21        // This sysvar is too large to bincode::deserialize in-program
22        Err(ProgramError::UnsupportedSysvar)
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    #[test]
30    fn test_size_of() {
31        assert_eq!(
32            SlotHistory::size_of(),
33            bincode::serialized_size(&SlotHistory::default()).unwrap() as usize
34        );
35    }
36}