accounts index get returns value (#19777)

This commit is contained in:
Jeff Washington (jwash) 2021-09-11 13:28:56 -05:00 committed by GitHub
parent 999ba9e026
commit 7de2236284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -246,9 +246,10 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
reclaims: &mut SlotList<T>,
previous_slot_entry_was_cached: bool,
) -> bool {
// (possibly) non-ideal clone of arc here
if let Some(current) = r_account_maps.get(pubkey) {
Self::lock_and_update_slot_list(
current,
&current,
new_value,
reclaims,
previous_slot_entry_was_cached,
@ -1191,7 +1192,6 @@ impl<T: IsCached> AccountsIndex<T> {
lock: &AccountMapsReadLock<'_, T>,
) -> Option<ReadAccountMapEntry<T>> {
lock.get(pubkey)
.cloned()
.map(ReadAccountMapEntry::from_account_map_entry)
}
@ -1200,7 +1200,6 @@ impl<T: IsCached> AccountsIndex<T> {
.read()
.unwrap()
.get(pubkey)
.cloned()
.map(WriteAccountMapEntry::from_account_map_entry)
}
@ -1459,7 +1458,6 @@ impl<T: IsCached> AccountsIndex<T> {
.unwrap();
let account = read_lock
.get(pubkey)
.cloned()
.map(ReadAccountMapEntry::from_account_map_entry);
match account {

View File

@ -34,8 +34,8 @@ impl<V: IsCached> InMemAccountsIndex<V> {
self.map.keys()
}
pub fn get(&self, key: &K) -> Option<&AccountMapEntry<V>> {
self.map.get(key)
pub fn get(&self, key: &K) -> Option<AccountMapEntry<V>> {
self.map.get(key).cloned()
}
pub fn remove(&mut self, key: &K) {