From 38ea3aa31a5c2db52596a10a988d4f22d11b2bac Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 21 Sep 2021 08:41:39 -0500 Subject: [PATCH] AcctIdx: keys impl when items are on disk (#20039) --- runtime/src/in_mem_accounts_index.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index a65a7d8b9..efc9f7a13 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -93,9 +93,15 @@ impl InMemAccountsIndex { result } + // only called in debug code paths pub fn keys(&self) -> Vec { 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>); + let keys = self.map().read().unwrap().keys().cloned().collect(); + self.start_stop_flush(false); + keys } pub fn get(&self, key: &K) -> Option> {