move AccountInfo to its own file (#21784)

This commit is contained in:
Jeff Washington (jwash) 2021-12-11 11:47:05 -06:00 committed by GitHub
parent c5c699a918
commit ef7f49a21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 23 deletions

View File

@ -5,7 +5,7 @@ extern crate test;
use {
rand::{thread_rng, Rng},
solana_runtime::{
accounts_db::AccountInfo,
account_info::AccountInfo,
accounts_index::{
AccountSecondaryIndexes, AccountsIndex, ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS,
},

View File

@ -0,0 +1,24 @@
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
pub offset: usize,
/// needed to track shrink candidacy in bytes. Used to update the number
/// of alive bytes in an AppendVec as newer slots purge outdated entries
pub stored_size: usize,
/// lamports in the account used when squashing kept for optimization
/// purposes to remove accounts with zero balance.
pub lamports: u64,
}
impl ZeroLamport for AccountInfo {
fn is_zero_lamport(&self) -> bool {
self.lamports == 0
}
}

View File

@ -22,6 +22,7 @@
use std::{thread::sleep, time::Duration};
use {
crate::{
account_info::AccountInfo,
accounts_background_service::{DroppedSlotsSender, SendDroppedBankCallback},
accounts_cache::{AccountsCache, CachedAccount, SlotCache},
accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats, PreviousPass},
@ -303,22 +304,6 @@ impl GenerateIndexTimings {
}
}
#[derive(Default, Debug, PartialEq, Clone, Copy)]
pub struct AccountInfo {
/// index identifying the append storage
store_id: AppendVecId,
/// offset into the storage
offset: usize,
/// needed to track shrink candidacy in bytes. Used to update the number
/// of alive bytes in an AppendVec as newer slots purge outdated entries
stored_size: usize,
/// lamports in the account used when squashing kept for optimization
/// purposes to remove accounts with zero balance.
lamports: u64,
}
impl IsCached for AccountInfo {
fn is_cached(&self) -> bool {
self.store_id == CACHE_VIRTUAL_STORAGE_ID
@ -327,12 +312,6 @@ impl IsCached for AccountInfo {
impl IndexValue for AccountInfo {}
impl ZeroLamport for AccountInfo {
fn is_zero_lamport(&self) -> bool {
self.lamports == 0
}
}
impl ZeroLamport for AccountSharedData {
fn is_zero_lamport(&self) -> bool {
self.lamports() == 0

View File

@ -1,5 +1,6 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
pub mod account_info;
pub mod accounts;
pub mod accounts_background_service;
pub mod accounts_cache;