Skip to main content

spherenet_program_whitelist_interface/state/
whitelist_entry.rs

1use {
2    super::{AccountState, Initializable},
3    bytemuck::{Pod, Zeroable},
4    pinocchio::pubkey::Pubkey,
5    shank::ShankAccount,
6};
7
8/// Offset of the entry_address field in the account data
9pub const ENTRY_ADDRESS_OFFSET: usize = 0;
10/// Offset of the state field in the account data
11pub const STATE_OFFSET: usize = 32;
12
13#[repr(C)]
14#[derive(Copy, Clone, Pod, Zeroable, ShankAccount)]
15pub struct ProgramWhitelistEntry {
16    pub entry_address: Pubkey,
17    pub state: u8,
18}
19
20impl ProgramWhitelistEntry {
21    #[inline(always)]
22    pub fn set_initialized(&mut self) {
23        self.state = AccountState::Initialized as u8;
24    }
25}
26
27impl Initializable for ProgramWhitelistEntry {
28    #[inline(always)]
29    fn is_initialized(&self) -> bool {
30        self.state != AccountState::Uninitialized as u8
31    }
32}