Fix roots never being purged (#4134)
This commit is contained in:
parent
f3f416b7ba
commit
5bb75a5894
|
@ -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]
|
||||||
|
|
Loading…
Reference in New Issue