Merge pull request #718 from ethereum/empty-base-reward

handle get_base_reward when no previous balance
This commit is contained in:
Danny Ryan 2019-03-05 09:24:12 -07:00 committed by GitHub
commit be1cb4a850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -2169,6 +2169,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
```