Update previous epoch function

This commit is contained in:
Paul Hauner 2019-02-16 15:09:43 +11:00
parent b79f0cdf68
commit f83d02b394
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -203,7 +203,12 @@ impl BeaconState {
///
/// Spec v0.2.0
pub fn previous_epoch(&self, spec: &ChainSpec) -> Epoch {
self.current_epoch(spec).saturating_sub(1_u64)
let current_epoch = self.current_epoch(&spec);
if current_epoch == spec.genesis_epoch {
current_epoch
} else {
current_epoch - 1
}
}
/// The epoch following `self.current_epoch()`.