Refactors AccountsIndex::get() (#35163)

This commit is contained in:
Brooks 2024-02-09 18:26:51 -05:00 committed by GitHub
parent 8f7fda8b9f
commit b5e903d1d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 15 deletions

View File

@ -1441,22 +1441,13 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
ancestors: Option<&Ancestors>,
max_root: Option<Slot>,
) -> AccountIndexGetResult<T> {
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`