diff --git a/runtime/src/account_info.rs b/runtime/src/account_info.rs index 04b72081d5ca38..7a526db41c445b 100644 --- a/runtime/src/account_info.rs +++ b/runtime/src/account_info.rs @@ -10,6 +10,9 @@ use crate::{ /// offset within an append vec to account data pub type Offset = usize; +/// bytes used to store this account in append vec +pub type StoredSize = usize; + /// specify where account data is located #[derive(Debug)] pub enum StorageLocation { @@ -61,7 +64,7 @@ pub struct AccountInfo { /// needed to track shrink candidacy in bytes. Used to update the number /// of alive bytes in an AppendVec as newer slots purge outdated entries /// Note that highest bit is used for ZERO_LAMPORT_BIT - stored_size: usize, + stored_size: StoredSize, } /// presence of this bit in stored_size indicates this account info references an account with zero lamports @@ -86,7 +89,11 @@ impl IsCached for StorageLocation { } impl AccountInfo { - pub fn new(storage_location: StorageLocation, mut stored_size: usize, lamports: u64) -> Self { + pub fn new( + storage_location: StorageLocation, + mut stored_size: StoredSize, + lamports: u64, + ) -> Self { let (store_id, offset) = match storage_location { StorageLocation::AppendVec(store_id, offset) => (store_id, offset), StorageLocation::Cached => (CACHE_VIRTUAL_STORAGE_ID, CACHE_VIRTUAL_OFFSET), @@ -102,15 +109,15 @@ impl AccountInfo { } } - pub fn store_id(&self) -> usize { + pub fn store_id(&self) -> AppendVecId { self.store_id } - pub fn offset(&self) -> usize { + pub fn offset(&self) -> Offset { self.offset } - pub fn stored_size(&self) -> usize { + pub fn stored_size(&self) -> StoredSize { // elminate the special bit that indicates the info references an account with zero lamports self.stored_size & !ZERO_LAMPORT_BIT }