Merge pull request #328 from ethereum/vbuterin-patch-19

Remove clamp
This commit is contained in:
vbuterin 2018-12-17 04:17:02 -05:00 committed by GitHub
commit 4aa6e4de7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 19 deletions

View File

@ -65,7 +65,6 @@
- [`get_active_validator_indices`](#get_active_validator_indices)
- [`shuffle`](#shuffle)
- [`split`](#split)
- [`clamp`](#clamp)
- [`get_new_shuffling`](#get_new_shuffling)
- [`get_shard_committees_at_slot`](#get_shard_committees_at_slot)
- [`get_block_root`](#get_block_root)
@ -834,21 +833,6 @@ def split(values: List[Any], split_count: int) -> List[Any]:
]
```
#### `clamp`
```python
def clamp(minval: int, maxval: int, x: int) -> int:
"""
Clamps ``x`` between ``minval`` and ``maxval``.
"""
if x <= minval:
return minval
elif x >= maxval:
return maxval
else:
return x
```
#### `get_new_shuffling`
```python
@ -860,11 +844,13 @@ def get_new_shuffling(seed: Hash32,
"""
active_validator_indices = get_active_validator_indices(validators)
committees_per_slot = clamp(
committees_per_slot = max(
1,
min(
SHARD_COUNT // EPOCH_LENGTH,
len(active_validator_indices) // EPOCH_LENGTH // TARGET_COMMITTEE_SIZE,
)
)
# Shuffle with seed
shuffled_active_validator_indices = shuffle(active_validator_indices, seed)