use anchor_lang::prelude::*;
use std::mem::size_of;
#[account]
pub struct UserAddressLookupTable {
pub bump: u8,
pub signer: Pubkey,
pub size: u64,
pub id: u64,
pub address_lookup_table: Pubkey,
pub last_updated_slot: u64,
}
impl UserAddressLookupTable {
pub const SEED: &'static str = "UserAddressLookupTable";
pub const COOLDOWN_SLOTS: u64 = 15;
pub const MAX_ADDRESSES: usize = 256;
pub const SIZE: usize = 8 + size_of::<u8>() + size_of::<Pubkey>() + size_of::<u64>() + size_of::<u64>() + size_of::<Pubkey>() + size_of::<u64>();
pub fn is_ready(&self, current_slot: u64) -> bool {
current_slot >= self.last_updated_slot.saturating_add(Self::COOLDOWN_SLOTS)
}
pub fn seeds(&self) -> Vec<Vec<u8>> {
vec![
Self::SEED.as_bytes().to_vec(),
self.signer.to_bytes().to_vec(),
self.id.to_le_bytes().to_vec(),
vec![self.bump],
]
}
}