Fix incorrect cache drops in advance_caches

This commit is contained in:
Michael Sproul
2019-11-18 12:12:03 +11:00
parent 2ed8eca0c1
commit d9467a8ebb

View File

@@ -799,13 +799,11 @@ impl<T: EthSpec> BeaconState<T> {
/// ///
/// Note: whilst this function will preserve already-built caches, it will not build any. /// Note: whilst this function will preserve already-built caches, it will not build any.
pub fn advance_caches(&mut self) { pub fn advance_caches(&mut self) {
let next = Self::committee_cache_index(RelativeEpoch::Previous);
let current = Self::committee_cache_index(RelativeEpoch::Current);
let caches = &mut self.committee_caches[..]; let caches = &mut self.committee_caches[..];
caches.rotate_left(1); caches.rotate_left(1);
let next = Self::committee_cache_index(RelativeEpoch::Next);
caches[next] = CommitteeCache::default(); caches[next] = CommitteeCache::default();
caches[current] = CommitteeCache::default();
} }
fn committee_cache_index(relative_epoch: RelativeEpoch) -> usize { fn committee_cache_index(relative_epoch: RelativeEpoch) -> usize {