2021-12-11 09:47:05 -08:00
|
|
|
use crate::{accounts_db::AppendVecId, accounts_index::ZeroLamport};
|
|
|
|
|
|
|
|
#[derive(Default, Debug, PartialEq, Clone, Copy)]
|
|
|
|
pub struct AccountInfo {
|
|
|
|
/// index identifying the append storage
|
|
|
|
pub store_id: AppendVecId,
|
|
|
|
|
|
|
|
/// offset into the storage
|
2021-12-13 12:43:26 -08:00
|
|
|
offset: usize,
|
2021-12-11 09:47:05 -08:00
|
|
|
|
|
|
|
/// needed to track shrink candidacy in bytes. Used to update the number
|
|
|
|
/// of alive bytes in an AppendVec as newer slots purge outdated entries
|
2021-12-13 08:10:06 -08:00
|
|
|
stored_size: usize,
|
2021-12-11 09:47:05 -08:00
|
|
|
|
|
|
|
/// lamports in the account used when squashing kept for optimization
|
|
|
|
/// purposes to remove accounts with zero balance.
|
2021-12-13 08:59:33 -08:00
|
|
|
lamports: u64,
|
2021-12-11 09:47:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ZeroLamport for AccountInfo {
|
|
|
|
fn is_zero_lamport(&self) -> bool {
|
|
|
|
self.lamports == 0
|
|
|
|
}
|
|
|
|
}
|
2021-12-12 12:36:05 -08:00
|
|
|
|
|
|
|
impl AccountInfo {
|
|
|
|
pub fn new(store_id: AppendVecId, offset: usize, stored_size: usize, lamports: u64) -> Self {
|
|
|
|
Self {
|
|
|
|
store_id,
|
|
|
|
offset,
|
|
|
|
stored_size,
|
|
|
|
lamports,
|
|
|
|
}
|
|
|
|
}
|
2021-12-13 08:10:06 -08:00
|
|
|
|
2021-12-13 12:43:26 -08:00
|
|
|
pub fn offset(&self) -> usize {
|
|
|
|
self.offset
|
|
|
|
}
|
|
|
|
|
2021-12-13 08:10:06 -08:00
|
|
|
pub fn stored_size(&self) -> usize {
|
|
|
|
self.stored_size
|
|
|
|
}
|
2021-12-12 12:36:05 -08:00
|
|
|
}
|