Add build_all_caches method to BeaconState

Also adds a few more cache builds in BeaconChain.
This commit is contained in:
Paul Hauner
2019-03-31 13:40:12 +11:00
parent 4e71ed6972
commit b26f1f8e1c
2 changed files with 25 additions and 9 deletions

View File

@@ -661,6 +661,17 @@ impl BeaconState {
})
}
/// Build all the caches, if they need to be built.
pub fn build_all_caches(&mut self, spec: &ChainSpec) -> Result<(), Error> {
self.build_epoch_cache(RelativeEpoch::Previous, spec)?;
self.build_epoch_cache(RelativeEpoch::Current, spec)?;
self.build_epoch_cache(RelativeEpoch::NextWithoutRegistryChange, spec)?;
self.build_epoch_cache(RelativeEpoch::NextWithRegistryChange, spec)?;
self.update_pubkey_cache()?;
Ok(())
}
/// Build an epoch cache, unless it is has already been built.
pub fn build_epoch_cache(
&mut self,