use {
serde::{Deserialize, Serialize},
solana_accounts_db::account_storage_entry::AccountStorageEntry,
solana_clock::Slot,
wincode::{SchemaRead, SchemaWrite},
};
pub(crate) type SerializedAccountsFileId = usize;
#[repr(C)]
#[cfg_attr(
feature = "frozen-abi",
derive(StableAbi, StableAbiSample),
frozen_abi(
abi_digest = "CMckX3HiC6K5FSmFo4tH44wU1mvGfabNtYAs65uaGvGU",
abi_serializer = ["bincode", "wincode"],
test_roundtrip = "eq_and_wire"
)
)]
#[derive(
Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, SchemaRead, SchemaWrite,
)]
pub struct SerializableAccountStorageEntry {
id: SerializedAccountsFileId,
accounts_current_len: usize,
}
impl SerializableAccountStorageEntry {
pub fn new(
accounts: &AccountStorageEntry,
snapshot_slot: Slot,
) -> SerializableAccountStorageEntry {
SerializableAccountStorageEntry {
id: accounts.id() as SerializedAccountsFileId,
accounts_current_len: accounts.accounts.len()
- accounts.get_obsolete_bytes(Some(snapshot_slot)),
}
}
}