create helper fn for clarity (#27216)

This commit is contained in:
Jeff Washington (jwash) 2022-08-18 11:30:35 -05:00 committed by GitHub
parent f115e4d0ed
commit e0472050c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -279,7 +279,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
m.stop();
callback(if let Some(entry) = result {
entry.set_age(self.storage.future_age_to_flush());
self.set_age_to_future(entry);
Some(entry)
} else {
drop(map);
@ -305,6 +305,10 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
self.get_internal(pubkey, |entry| (true, entry.map(Arc::clone)))
}
fn set_age_to_future(&self, entry: &AccountMapEntry<T>) {
entry.set_age(self.storage.future_age_to_flush());
}
/// lookup 'pubkey' in index (in_mem or disk).
/// call 'callback' whether found or not
pub(crate) fn get_internal<RT>(
@ -473,7 +477,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
reclaims,
reclaim,
);
current.set_age(self.storage.future_age_to_flush());
self.set_age_to_future(current);
}
Entry::Vacant(vacant) => {
// not in cache, look on disk