Переглянути джерело

Ensures AccountMapEntry size doesn't change unexpectedly (#9125)

Brooks 3 днів тому
батько
коміт
68aa76c828

+ 3 - 0
accounts-db/src/account_info.rs

@@ -89,6 +89,9 @@ pub struct AccountInfo {
     account_offset_and_flags: PackedOffsetAndFlags,
 }
 
+// Ensure the size of AccountInfo never changes unexpectedly
+const _: () = assert!(size_of::<AccountInfo>() == 8);
+
 impl IsZeroLamport for AccountInfo {
     fn is_zero_lamport(&self) -> bool {
         self.account_offset_and_flags.is_zero_lamport()

+ 4 - 1
accounts-db/src/accounts_index/account_map_entry.rs

@@ -3,7 +3,7 @@ use {
         bucket_map_holder::{Age, AtomicAge, BucketMapHolder},
         AtomicRefCount, DiskIndexValue, IndexValue, RefCount, SlotList,
     },
-    crate::is_zero_lamport::IsZeroLamport,
+    crate::{account_info::AccountInfo, is_zero_lamport::IsZeroLamport},
     solana_clock::Slot,
     std::{
         fmt::Debug,
@@ -30,6 +30,9 @@ pub struct AccountMapEntry<T> {
     meta: AccountMapEntryMeta,
 }
 
+// Ensure the size of AccountMapEntry never changes unexpectedly
+const _: () = assert!(size_of::<AccountMapEntry<AccountInfo>>() == 48);
+
 impl<T: IndexValue> AccountMapEntry<T> {
     pub fn new(slot_list: SlotList<T>, ref_count: RefCount, meta: AccountMapEntryMeta) -> Self {
         Self {