From 825f8bcea4d0c117782d36e4aeb5d5ef9c1514ba Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Sat, 11 Dec 2021 21:38:13 -0600 Subject: [PATCH] use AppendVecId instead of usize (#21792) --- runtime/src/accounts_db.rs | 12 ++++++------ runtime/src/append_vec.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 7b81383acb..d2c9a2d95a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -371,7 +371,7 @@ pub type SnapshotStorage = Vec>; pub type SnapshotStorages = Vec; // Each slot has a set of storage entries. -pub(crate) type SlotStores = Arc>>>; +pub(crate) type SlotStores = Arc>>>; type AccountSlots = HashMap>; type AppendVecOffsets = HashMap>; @@ -654,7 +654,7 @@ pub struct AccountStorageEntry { } impl AccountStorageEntry { - pub fn new(path: &Path, slot: Slot, id: usize, file_size: u64) -> Self { + pub fn new(path: &Path, slot: Slot, id: AppendVecId, file_size: u64) -> Self { let tail = AppendVec::file_name(slot, id); let path = Path::new(path).join(tail); let accounts = AppendVec::new(&path, true, file_size as usize); @@ -706,7 +706,7 @@ impl AccountStorageEntry { *count_and_status = (count, status); } - pub fn recycle(&self, slot: Slot, id: usize) { + pub fn recycle(&self, slot: Slot, id: AppendVecId) { let mut count_and_status = self.count_and_status.write().unwrap(); self.accounts.reset(); *count_and_status = (0, AccountStorageStatus::Available); @@ -1843,7 +1843,7 @@ impl AccountsDb { no_delete }; if no_delete { - let mut pending_store_ids: HashSet = HashSet::new(); + let mut pending_store_ids = HashSet::new(); for (_bank_id, account_info) in account_infos { if !already_counted.contains(&account_info.store_id) { pending_store_ids.insert(account_info.store_id); @@ -3358,7 +3358,7 @@ impl AccountsDb { fn retry_to_get_account_accessor<'a>( &'a self, mut slot: Slot, - mut store_id: usize, + mut store_id: AppendVecId, mut offset: usize, ancestors: &'a Ancestors, pubkey: &'a Pubkey, @@ -3696,7 +3696,7 @@ impl AccountsDb { &'a self, slot: Slot, pubkey: &'a Pubkey, - store_id: usize, + store_id: AppendVecId, offset: usize, ) -> LoadedAccountAccessor<'a> { if store_id == CACHE_VIRTUAL_STORAGE_ID { diff --git a/runtime/src/append_vec.rs b/runtime/src/append_vec.rs index 1f49dfe111..29f13ee270 100644 --- a/runtime/src/append_vec.rs +++ b/runtime/src/append_vec.rs @@ -301,7 +301,7 @@ impl AppendVec { self.file_size } - pub fn file_name(slot: Slot, id: usize) -> String { + pub fn file_name(slot: Slot, id: impl std::fmt::Display) -> String { format!("{}.{}", slot, id) }