Added a note for underflow. Thanks Hsiao Wei! : )

Co-Authored-By: terenc3t <terence@prysmaticlabs.com>
This commit is contained in:
Hsiao-Wei Wang 2019-02-03 14:27:09 +01:00 committed by GitHub
parent e4c4c04e52
commit 3a6da9839a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -646,6 +646,7 @@ def slot_to_epoch(slot: SlotNumber) -> EpochNumber:
def get_previous_epoch(state: BeaconState) -> EpochNumber:
"""`
Return the previous epoch of the given ``state``.
If the current epoch is ``GENESIS_EPOCH``, return ``GENESIS_EPOCH``.
"""
if slot_to_epoch(state.slot) > GENESIS_EPOCH:
return slot_to_epoch(state.slot) - 1