From 7a997759fa374a0d78fd3f4f6e8a20454990ee09 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Mon, 5 Apr 2021 11:26:53 -0500 Subject: [PATCH] reduce locking on get_rooted_entries (#16304) --- runtime/src/accounts_index.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 2fdd778adc..7bdb1e42a4 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -685,9 +685,11 @@ impl AccountsIndex { } pub fn get_rooted_entries(&self, slice: SlotSlice, max: Option) -> SlotList { + let max = max.unwrap_or(Slot::MAX); + let lock = &self.roots_tracker.read().unwrap().roots; slice .iter() - .filter(|(slot, _)| self.is_root(*slot) && max.map_or(true, |max| *slot <= max)) + .filter(|(slot, _)| *slot <= max && lock.contains(slot)) .cloned() .collect() }