handle get_base_reward when no previous balance

This commit is contained in:
Danny Ryan 2019-03-04 19:05:00 -07:00
parent 0fdfbc473e
commit 02e8e89740
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 3 additions and 0 deletions

View File

@ -2171,6 +2171,9 @@ First, we define some additional helpers:
```python
def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
if get_previous_total_balance(state) == 0:
return 0
adjusted_quotient = integer_squareroot(get_previous_total_balance(state)) // BASE_REWARD_QUOTIENT
return get_effective_balance(state, index) // adjusted_quotient // 5
```