AcctIdx: keys impl when items are on disk (#20039)

This commit is contained in:
Jeff Washington (jwash) 2021-09-21 08:41:39 -05:00 committed by GitHub
parent fb71e80962
commit 38ea3aa31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -93,9 +93,15 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
result
}
// only called in debug code paths
pub fn keys(&self) -> Vec<Pubkey> {
Self::update_stat(&self.stats().keys, 1);
self.map().read().unwrap().keys().cloned().collect()
// easiest implementation is to load evrything from disk into cache and return the keys
self.start_stop_flush(true);
self.put_range_in_cache(None::<&RangeInclusive<Pubkey>>);
let keys = self.map().read().unwrap().keys().cloned().collect();
self.start_stop_flush(false);
keys
}
pub fn get(&self, key: &K) -> Option<AccountMapEntry<T>> {