AccountsIndex::get_cloned() *must* add entry to in-mem cache (#35322)
This commit is contained in:
parent
8143fc3f4a
commit
bf2e8ee32f
|
@ -1158,9 +1158,11 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
|
|||
/// Gets the index's entry for `pubkey` and clones it
|
||||
///
|
||||
/// Prefer `get_and_then()` whenever possible.
|
||||
/// NOTE: The entry is *not* added to the in-mem cache.
|
||||
pub fn get_cloned(&self, pubkey: &Pubkey) -> Option<AccountMapEntry<T>> {
|
||||
self.get_and_then(pubkey, |entry| (false, entry.cloned()))
|
||||
// We *must* add the index entry to the in-mem cache!
|
||||
// If the index entry is only on-disk, returning a clone would allow the entry
|
||||
// to be modified, but those modifications would be lost on drop!
|
||||
self.get_and_then(pubkey, |entry| (true, entry.cloned()))
|
||||
}
|
||||
|
||||
/// Is `pubkey` in the index?
|
||||
|
|
Loading…
Reference in New Issue