Remove unnecesary flushes in previous roots (#14596)
Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@@ -956,6 +956,23 @@ impl<T: 'static + Clone + IsCached> AccountsIndex<T> {
|
||||
std::mem::replace(&mut w_roots_tracker.previous_uncleaned_roots, cleaned_roots)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn clear_uncleaned_roots(&self, max_clean_root: Option<Slot>) -> HashSet<Slot> {
|
||||
let mut cleaned_roots = HashSet::new();
|
||||
let mut w_roots_tracker = self.roots_tracker.write().unwrap();
|
||||
w_roots_tracker.uncleaned_roots.retain(|root| {
|
||||
let is_cleaned = max_clean_root
|
||||
.map(|max_clean_root| *root <= max_clean_root)
|
||||
.unwrap_or(true);
|
||||
if is_cleaned {
|
||||
cleaned_roots.insert(*root);
|
||||
}
|
||||
// Only keep the slots that have yet to be cleaned
|
||||
!is_cleaned
|
||||
});
|
||||
cleaned_roots
|
||||
}
|
||||
|
||||
pub fn is_uncleaned_root(&self, slot: Slot) -> bool {
|
||||
self.roots_tracker
|
||||
.read()
|
||||
|
Reference in New Issue
Block a user