From 2a795614d3a60e87614c6647f39dd77ba6106c95 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 14 Sep 2021 09:38:59 -0500 Subject: [PATCH] accounts index keys returns by value (#19858) --- runtime/src/accounts_db.rs | 2 +- runtime/src/in_mem_accounts_index.rs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 5febd52a91..3074bb4f0e 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -4797,7 +4797,7 @@ impl AccountsDb { .account_maps .iter() .map(|map| { - let mut keys = map.read().unwrap().keys().cloned().collect::>(); + let mut keys = map.read().unwrap().keys(); keys.sort_unstable(); // hashmap is not ordered, but bins are relative to each other keys }) diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index 4f19acc7e1..b2f5897448 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -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 InMemAccountsIndex { result } - pub fn keys(&self) -> Keys> { + pub fn keys(&self) -> Vec { Self::update_stat(&self.stats().keys, 1); - self.map.keys() + self.map.keys().cloned().collect() } pub fn get(&self, key: &K) -> Option> {