accounts index keys returns by value (#19858)

This commit is contained in:
Jeff Washington (jwash) 2021-09-14 09:38:59 -05:00 committed by GitHub
parent 46d1b61902
commit 2a795614d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -4797,7 +4797,7 @@ impl AccountsDb {
.account_maps
.iter()
.map(|map| {
let mut keys = map.read().unwrap().keys().cloned().collect::<Vec<_>>();
let mut keys = map.read().unwrap().keys();
keys.sort_unstable(); // hashmap is not ordered, but bins are relative to each other
keys
})

View File

@ -6,10 +6,7 @@ use crate::bucket_map_holder::BucketMapHolder;
use crate::bucket_map_holder_stats::BucketMapHolderStats;
use solana_measure::measure::Measure;
use solana_sdk::{clock::Slot, pubkey::Pubkey};
use std::collections::{
hash_map::{Entry, Keys},
HashMap,
};
use std::collections::{hash_map::Entry, HashMap};
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
@ -67,9 +64,9 @@ impl<T: IsCached> InMemAccountsIndex<T> {
result
}
pub fn keys(&self) -> Keys<K, AccountMapEntry<T>> {
pub fn keys(&self) -> Vec<Pubkey> {
Self::update_stat(&self.stats().keys, 1);
self.map.keys()
self.map.keys().cloned().collect()
}
pub fn get(&self, key: &K) -> Option<AccountMapEntry<T>> {