use crate::accounts::account_header::AccountHeader;
use crate::accounts::devol_account::DevolAccount;
use crate::accounts::devol_indexed_account::DevolIndexedAccount;
use crate::accounts::worker::pool_logs::pool_log_record::PoolLogRecord;
pub const POOLS_LOG_BUFFER_CAPACITY: usize = 256;
pub const POOLS_LOG_ACCOUNT_SIZE: usize = 340024;
pub const POOLS_LOG_ACCOUNT_TAG: u8 = 6;
pub const POOLS_LOG_ACCOUNT_VERSION: u32 = 9;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct PoolLogsAccount {
pub header: AccountHeader, pub worker_id: u32, pub last_pool_id: u32, pub pools_count: u32, reserved: u32, pub pool_log_records: [PoolLogRecord; POOLS_LOG_BUFFER_CAPACITY], }
impl DevolIndexedAccount for PoolLogsAccount {}
impl DevolAccount for PoolLogsAccount {
#[inline(always)]
fn expected_size() -> usize { POOLS_LOG_ACCOUNT_SIZE }
#[inline(always)]
fn expected_tag() -> u8 {
POOLS_LOG_ACCOUNT_TAG
}
#[inline(always)]
fn expected_version() -> u32 {
POOLS_LOG_ACCOUNT_VERSION
}
}
impl Default for PoolLogsAccount {
fn default() -> Self {
Self {
header: AccountHeader::default(),
worker_id: 0,
last_pool_id: 0,
pools_count: 0,
reserved: 0,
pool_log_records: [PoolLogRecord::default(); POOLS_LOG_BUFFER_CAPACITY],
}
}
}
#[cfg(test)]
mod tests {
use crate::utils::type_size_helper::align_size;
use super::*;
#[test]
fn test_pools_log_account_offsets() {
let account = PoolLogsAccount::default();
let base_ptr = &account as *const _ as usize;
assert_eq!(
&account.header as *const _ as usize - base_ptr,
0
);
let real_size = std::mem::size_of::<PoolLogsAccount>();
assert_eq!(real_size, POOLS_LOG_ACCOUNT_SIZE);
assert_eq!(real_size, align_size(real_size, 8));
}
}