AcctIdx: consolidate next_id calls (#21929)

This commit is contained in:
Jeff Washington (jwash) 2021-12-15 15:39:54 -06:00 committed by GitHub
parent 882f886450
commit e5be96d8bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -1714,13 +1714,14 @@ impl AccountsDb {
}
}
fn next_id(&self) -> AppendVecId {
let next_id = self.next_id.fetch_add(1, Ordering::AcqRel);
assert!(next_id != AppendVecId::MAX, "We've run out of storage ids!");
next_id
}
fn new_storage_entry(&self, slot: Slot, path: &Path, size: u64) -> AccountStorageEntry {
AccountStorageEntry::new(
path,
slot,
self.next_id.fetch_add(1, Ordering::AcqRel),
size,
)
AccountStorageEntry::new(path, slot, self.next_id(), size)
}
pub fn expected_cluster_type(&self) -> ClusterType {
@ -3732,7 +3733,7 @@ impl AccountsDb {
let ret = recycle_stores.remove_entry(i);
drop(recycle_stores);
let old_id = ret.append_vec_id();
ret.recycle(slot, self.next_id.fetch_add(1, Ordering::AcqRel));
ret.recycle(slot, self.next_id());
debug!(
"recycling store: {} {:?} old_id: {}",
ret.append_vec_id(),