fix markdown issues
This commit is contained in:
parent
47477b8e55
commit
f6da42ffb3
|
@ -760,31 +760,32 @@ def get_active_validator_indices(validators: List[Validator], epoch: Epoch) -> L
|
|||
def get_balance(state: BeaconState, index: int) -> int:
|
||||
return state.balances[index]
|
||||
```
|
||||
#### `set_balance`
|
||||
|
||||
````python
|
||||
### `set_balance`
|
||||
|
||||
```python
|
||||
def set_balance(state: BeaconState, index: int, balance: int) -> None:
|
||||
validator = state.validator_registry[index]
|
||||
HALF_INCREMENT = HIGH_BALANCE_INCREMENT // 2
|
||||
if validator.high_balance > balance or validator.high_balance + 3 * HALF_INCREMENT < balance:
|
||||
validator.high_balance = balance - balance % HIGH_BALANCE_INCREMENT
|
||||
state.balances[index] = balance
|
||||
````
|
||||
```
|
||||
|
||||
#### `increase_balance`
|
||||
### `increase_balance`
|
||||
|
||||
````python
|
||||
```python
|
||||
def increase_balance(state: BeaconState, index: int, delta: int) -> None:
|
||||
set_balance(state, index, get_balance(state, index) + delta)
|
||||
````
|
||||
```
|
||||
|
||||
#### `decrease_balance`
|
||||
### `decrease_balance`
|
||||
|
||||
````python
|
||||
```python
|
||||
def decrease_balance(state: BeaconState, index: int, delta: int) -> None:
|
||||
cur_balance = get_balance(state, index)
|
||||
set_balance(state, index, cur_balance - delta if cur_balance >= delta else 0)
|
||||
````
|
||||
```
|
||||
|
||||
### `get_permuted_index`
|
||||
|
||||
|
|
Loading…
Reference in New Issue