Fix roots never being purged (#4134)

This commit is contained in:
carllin 2019-05-03 15:17:37 -07:00 committed by GitHub
parent f3f416b7ba
commit 5bb75a5894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -60,7 +60,7 @@ impl<T: Clone> AccountsIndex<T> {
rv rv
} }
pub fn is_purged(&self, fork: Fork) -> bool { pub fn is_purged(&self, fork: Fork) -> bool {
!self.is_root(fork) && fork < self.last_root fork < self.last_root
} }
pub fn is_root(&self, fork: Fork) -> bool { pub fn is_root(&self, fork: Fork) -> bool {
self.roots.contains(&fork) self.roots.contains(&fork)
@ -152,6 +152,8 @@ mod tests {
assert!(!index.is_purged(0)); assert!(!index.is_purged(0));
index.add_root(1); index.add_root(1);
assert!(index.is_purged(0)); assert!(index.is_purged(0));
index.add_root(2);
assert!(index.is_purged(1));
} }
#[test] #[test]