Minor fixes

This commit is contained in:
Justin Drake 2019-07-05 15:03:37 +01:00
parent a63de3dc37
commit c8c810c0e1
1 changed files with 6 additions and 6 deletions

View File

@ -540,8 +540,6 @@ class BeaconState(Container):
### Math ### Math
#### `int_to_bytes`
#### `integer_squareroot` #### `integer_squareroot`
```python ```python
@ -560,13 +558,15 @@ def integer_squareroot(n: uint64) -> uint64:
#### `xor` #### `xor`
```python ```python
def xor(bytes1: Bytes32, bytes2: Bytes32) -> Bytes32: def xor(bytes_1: Bytes32, bytes_2: Bytes32) -> Bytes32:
""" """
Return the exclusive-or of two 32-byte strings. Return the exclusive-or of two 32-byte strings.
""" """
return Bytes32(a ^ b for a, b in zip(bytes1, bytes2)) return Bytes32(a ^ b for a, b in zip(bytes_1, bytes_2))
``` ```
#### `int_to_bytes`
```python ```python
def int_to_bytes(n: uint64, length: uint64) -> bytes: def int_to_bytes(n: uint64, length: uint64) -> bytes:
""" """
@ -653,7 +653,7 @@ def is_slashable_attestation_data(data_1: AttestationData, data_2: AttestationDa
```python ```python
def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: IndexedAttestation) -> bool: def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: IndexedAttestation) -> bool:
""" """
Verify validity of ``indexed_attestation``. Check indices and signature of ``indexed_attestation``.
""" """
bit_0_indices = indexed_attestation.custody_bit_0_indices bit_0_indices = indexed_attestation.custody_bit_0_indices
bit_1_indices = indexed_attestation.custody_bit_1_indices bit_1_indices = indexed_attestation.custody_bit_1_indices
@ -989,7 +989,7 @@ def get_total_balance(state: BeaconState, indices: Set[ValidatorIndex]) -> Gwei:
""" """
Return the combined effective balance of the ``indices``. (1 Gwei minimum to avoid divisions by zero.) Return the combined effective balance of the ``indices``. (1 Gwei minimum to avoid divisions by zero.)
""" """
return Gwei(max(sum([state.validators[index].effective_balance for index in indices]), 1)) return Gwei(max(1, sum([state.validators[index].effective_balance for index in indices])))
``` ```
#### `get_total_active_balance` #### `get_total_active_balance`