diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index 756526e89..2c2935d10 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -1950,31 +1950,6 @@ impl + Into> AccountsIndex { w_roots_tracker.previous_uncleaned_roots = cleaned_roots; } - #[cfg(test)] - pub fn clear_uncleaned_roots(&self, max_clean_root: Option) -> HashSet { - 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() - .unwrap() - .uncleaned_roots - .contains(&slot) - } - pub fn num_alive_roots(&self) -> usize { self.roots_tracker.read().unwrap().alive_roots.len() } @@ -1984,11 +1959,6 @@ impl + Into> AccountsIndex { tracker.alive_roots.get_all() } - #[cfg(test)] - pub fn clear_roots(&self) { - self.roots_tracker.write().unwrap().alive_roots.clear() - } - pub fn clone_uncleaned_roots(&self) -> HashSet { self.roots_tracker.read().unwrap().uncleaned_roots.clone() } @@ -3902,6 +3872,34 @@ pub mod tests { ); assert!(gc.is_empty()); } + + pub fn clear_uncleaned_roots(&self, max_clean_root: Option) -> HashSet { + 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(crate) fn is_uncleaned_root(&self, slot: Slot) -> bool { + self.roots_tracker + .read() + .unwrap() + .uncleaned_roots + .contains(&slot) + } + + pub fn clear_roots(&self) { + self.roots_tracker.write().unwrap().alive_roots.clear() + } } #[test]