clean_rooted_entries adds _EXclusive (#27309)
This commit is contained in:
parent
a8543ad992
commit
2014525882
|
@ -1708,6 +1708,9 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||
|
||||
slot_list.retain(|(slot, value)| {
|
||||
let should_purge = Self::can_purge_older_entries(
|
||||
// Note that we have a root that is inclusive here.
|
||||
// Calling a function that expects 'exclusive'
|
||||
// This is expected behavior for this call.
|
||||
max_clean_root_inclusive,
|
||||
newest_root_in_slot_list,
|
||||
*slot,
|
||||
|
@ -1744,21 +1747,21 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||
/// When can an entry be purged?
|
||||
///
|
||||
/// If we get a slot update where slot != newest_root_in_slot_list for an account where slot <
|
||||
/// max_clean_root, then we know it's safe to delete because:
|
||||
/// max_clean_root_exclusive, then we know it's safe to delete because:
|
||||
///
|
||||
/// a) If slot < newest_root_in_slot_list, then we know the update is outdated by a later rooted
|
||||
/// update, namely the one in newest_root_in_slot_list
|
||||
///
|
||||
/// b) If slot > newest_root_in_slot_list, then because slot < max_clean_root and we know there are
|
||||
/// no roots in the slot list between newest_root_in_slot_list and max_clean_root, (otherwise there
|
||||
/// b) If slot > newest_root_in_slot_list, then because slot < max_clean_root_exclusive and we know there are
|
||||
/// no roots in the slot list between newest_root_in_slot_list and max_clean_root_exclusive, (otherwise there
|
||||
/// would be a bigger newest_root_in_slot_list, which is a contradiction), then we know slot must be
|
||||
/// an unrooted slot less than max_clean_root and thus safe to clean as well.
|
||||
/// an unrooted slot less than max_clean_root_exclusive and thus safe to clean as well.
|
||||
fn can_purge_older_entries(
|
||||
max_clean_root: Slot,
|
||||
max_clean_root_exclusive: Slot,
|
||||
newest_root_in_slot_list: Slot,
|
||||
slot: Slot,
|
||||
) -> bool {
|
||||
slot < max_clean_root && slot != newest_root_in_slot_list
|
||||
slot < max_clean_root_exclusive && slot != newest_root_in_slot_list
|
||||
}
|
||||
|
||||
/// Given a list of slots, return a new list of only the slots that are rooted
|
||||
|
|
Loading…
Reference in New Issue