diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 03c5260a38..341288eb84 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -6461,7 +6461,7 @@ impl AccountsDb { roots.sort(); info!("{}: accounts_index roots: {:?}", label, roots,); self.accounts_index.account_maps.iter().for_each(|map| { - for (pubkey, account_entry) in map.read().unwrap().iter() { + for (pubkey, account_entry) in map.read().unwrap().items() { info!(" key: {} ref_count: {}", pubkey, account_entry.ref_count(),); info!( " slots: {:?}", diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 9e4346d8dd..5877808903 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -640,9 +640,9 @@ impl<'a, T: IsCached> AccountsIndexIterator<'a, T> { R: RangeBounds, { let mut result = Vec::with_capacity(map.len()); - for (k, v) in map.iter() { - if range.contains(k) { - result.push((*k, v.clone())); + for (k, v) in map.items() { + if range.contains(&k) { + result.push((k, v)); } } if !collect_all_unsorted { diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index d44a189a55..229ce78a8a 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -1,7 +1,7 @@ use crate::accounts_index::{AccountMapEntry, IsCached}; use solana_sdk::pubkey::Pubkey; use std::collections::{ - hash_map::{Entry, Iter, Keys}, + hash_map::{Entry, Keys}, HashMap, }; use std::fmt::Debug; @@ -26,8 +26,8 @@ impl InMemAccountsIndex { self.map.entry(pubkey) } - pub fn iter(&self) -> Iter> { - self.map.iter() + pub fn items(&self) -> Vec<(K, AccountMapEntry)> { + self.map.iter().map(|(k, v)| (*k, v.clone())).collect() } pub fn keys(&self) -> Keys> {