Skip to content

Commit

Permalink
Rename append_vec_id() to accounts_file_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
yhchiang-sol committed Mar 27, 2024
1 parent 80d3200 commit d7f2b5a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 64 deletions.
17 changes: 9 additions & 8 deletions accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ impl AccountStorage {
lookup_in_map()
.or_else(|| {
self.shrink_in_progress_map.get(&slot).and_then(|entry| {
(entry.value().append_vec_id() == store_id).then(|| Arc::clone(entry.value()))
(entry.value().accounts_file_id() == store_id)
.then(|| Arc::clone(entry.value()))
})
})
.or_else(lookup_in_map)
Expand Down Expand Up @@ -139,7 +140,7 @@ impl AccountStorage {
.insert(
slot,
AccountStorageReference {
id: store.append_vec_id(),
id: store.accounts_file_id(),
storage: store,
}
)
Expand Down Expand Up @@ -236,11 +237,11 @@ impl<'a> Drop for ShrinkInProgress<'a> {
self.slot,
AccountStorageReference {
storage: Arc::clone(&self.new_store),
id: self.new_store.append_vec_id()
id: self.new_store.accounts_file_id()
}
)
.map(|store| store.id),
Some(self.old_store.append_vec_id())
Some(self.old_store.accounts_file_id())
);

// The new store can be removed from 'shrink_in_progress_map'
Expand Down Expand Up @@ -475,22 +476,22 @@ pub(crate) mod tests {
assert!(storage.map.contains_key(&slot));
assert_eq!(
id_to_shrink,
storage.map.get(&slot).unwrap().storage.append_vec_id()
storage.map.get(&slot).unwrap().storage.accounts_file_id()
);
assert_eq!(
(slot, id_shrunk),
storage
.shrink_in_progress_map
.iter()
.next()
.map(|r| (*r.key(), r.value().append_vec_id()))
.map(|r| (*r.key(), r.value().accounts_file_id()))
.unwrap()
);
drop(shrinking_in_progress);
assert!(storage.map.contains_key(&slot));
assert_eq!(
id_shrunk,
storage.map.get(&slot).unwrap().storage.append_vec_id()
storage.map.get(&slot).unwrap().storage.accounts_file_id()
);
assert!(storage.shrink_in_progress_map.is_empty());
storage.shrinking_in_progress(slot, sample);
Expand Down Expand Up @@ -520,7 +521,7 @@ pub(crate) mod tests {
// verify data structures during and after shrink and then with subsequent shrink call
let storage = AccountStorage::default();
let sample = storage.get_test_storage();
let id = sample.append_vec_id();
let id = sample.accounts_file_id();
let missing_id = 9999;
let slot = sample.slot();
// id is missing since not in maps at all
Expand Down
Loading

0 comments on commit d7f2b5a

Please sign in to comment.