diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index 493bb3130..a3e7ff37b 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -1441,22 +1441,13 @@ impl + Into> AccountsIndex { ancestors: Option<&Ancestors>, max_root: Option, ) -> AccountIndexGetResult { - let read_lock = self.get_bin(pubkey); - let account = read_lock - .get(pubkey) - .map(ReadAccountMapEntry::from_account_map_entry); - - match account { - Some(locked_entry) => { + self.get_account_read_entry(pubkey) + .and_then(|locked_entry| { let slot_list = locked_entry.slot_list(); - let found_index = self.latest_slot(ancestors, slot_list, max_root); - match found_index { - Some(found_index) => AccountIndexGetResult::Found(locked_entry, found_index), - None => AccountIndexGetResult::NotFound, - } - } - None => AccountIndexGetResult::NotFound, - } + self.latest_slot(ancestors, slot_list, max_root) + .map(|found_index| AccountIndexGetResult::Found(locked_entry, found_index)) + }) + .unwrap_or(AccountIndexGetResult::NotFound) } // Get the maximum root <= `max_allowed_root` from the given `slice`