Skip to content

Commit

Permalink
Revert "get rid of unneeded mut and refactor addref (solana-labs#19594)"
Browse files Browse the repository at this point in the history
This reverts commit ca1b04e.
  • Loading branch information
frits-metalogix authored Nov 24, 2021
1 parent 5887d91 commit 2352542
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions runtime/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
.build()
}

pub fn slot_list(&self) -> &SlotList<T> {
pub fn slot_list(&mut self) -> &SlotList<T> {
&*self.borrow_slot_list_guard()
}

Expand All @@ -201,6 +201,10 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
self.with_slot_list_guard_mut(user)
}

pub fn ref_count(&self) -> &AtomicU64 {
&self.borrow_owned_entry().ref_count
}

// create an entry that is equivalent to this process:
// 1. new empty (refcount=0, slot_list={})
// 2. update(slot, account_info)
Expand Down Expand Up @@ -325,7 +329,7 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
});
if addref {
// If it's the first non-cache insert, also bump the stored ref count
self.borrow_owned_entry().add_un_ref(true);
self.ref_count().fetch_add(1, Ordering::Relaxed);
}
}
}
Expand Down

0 comments on commit 2352542

Please sign in to comment.