add `is_recyclable` to `AccountsFile` (#31257)

This commit is contained in:
Jeff Washington (jwash) 2023-04-19 13:36:44 -05:00 committed by GitHub
parent 9124d1f35d
commit 318f981274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -5551,7 +5551,10 @@ impl AccountsDb {
min = std::cmp::min(store.accounts.capacity(), min);
avail += 1;
if store.accounts.capacity() >= min_size && store.accounts.capacity() < max_size {
if store.accounts.is_recyclable()
&& store.accounts.capacity() >= min_size
&& store.accounts.capacity() < max_size
{
let ret = recycle_stores.remove_entry(i);
drop(recycle_stores);
let old_id = ret.append_vec_id();

View File

@ -86,6 +86,12 @@ impl AccountsFile {
}
}
pub fn is_recyclable(&self) -> bool {
match self {
Self::AppendVec(_) => true,
}
}
pub fn file_name(slot: Slot, id: impl std::fmt::Display) -> String {
format!("{slot}.{id}")
}