Skip to content

Commit

Permalink
Renames AccountStorageEntry::append_vec_id() to id() (solana-labs#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Jul 26, 2024
1 parent cdff19c commit d08b22f
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 109 deletions.
22 changes: 8 additions & 14 deletions accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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().id() == store_id).then(|| Arc::clone(entry.value()))
})
})
.or_else(lookup_in_map)
Expand Down Expand Up @@ -151,7 +151,7 @@ impl AccountStorage {
.insert(
slot,
AccountStorageReference {
id: store.append_vec_id(),
id: store.id(),
storage: store,
}
)
Expand Down Expand Up @@ -248,11 +248,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.id()
}
)
.map(|store| store.id),
Some(self.old_store.append_vec_id())
Some(self.old_store.id())
);

// The new store can be removed from 'shrink_in_progress_map'
Expand Down Expand Up @@ -489,25 +489,19 @@ pub(crate) mod tests {
);
let shrinking_in_progress = storage.shrinking_in_progress(slot, sample.clone());
assert!(storage.map.contains_key(&slot));
assert_eq!(
id_to_shrink,
storage.map.get(&slot).unwrap().storage.append_vec_id()
);
assert_eq!(id_to_shrink, storage.map.get(&slot).unwrap().storage.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().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()
);
assert_eq!(id_shrunk, storage.map.get(&slot).unwrap().storage.id());
assert!(storage.shrink_in_progress_map.is_empty());
storage.shrinking_in_progress(slot, sample);
}
Expand Down Expand Up @@ -536,7 +530,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.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 d08b22f

Please sign in to comment.