Merge pull request #820 from ethereum/vbuterin-patch-16

Add docstring into get_split_offset
This commit is contained in:
Danny Ryan 2019-03-21 08:26:13 -06:00 committed by GitHub
commit 5fef8ea339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View File

@ -778,8 +778,12 @@ def get_permuted_index(index: int, list_size: int, seed: Bytes32) -> int:
### `get_split_offset`
```python
def get_split_offset(list_length: int, split_count: int, index: int) -> int:
return (list_length * index) // split_count
def get_split_offset(list_size: int, chunks: int, index: int) -> int:
"""
Returns a value such that for a list L, chunk count k and index i,
split(L, k)[i] == L[get_split_offset(len(L), k, i): get_split_offset(len(L), k, i+1)]
"""
return (list_size * index) // chunks
```
### `get_epoch_committee_count`

View File

@ -19,7 +19,6 @@ At the current stage, Phase 1, while fundamentally feature-complete, is still su
- [Signature domains](#signature-domains)
- [Shard chains and crosslink data](#shard-chains-and-crosslink-data)
- [Helper functions](#helper-functions)
- [`get_split_offset`](#get_split_offset)
- [`get_shuffled_committee`](#get_shuffled_committee)
- [`get_persistent_committee`](#get_persistent_committee)
- [`get_shard_proposer_index`](#get_shard_proposer_index)
@ -122,17 +121,6 @@ Phase 1 depends upon all of the constants defined in [Phase 0](0_beacon-chain.md
## Helper functions
#### `get_split_offset`
````python
def get_split_offset(list_size: int, chunks: int, index: int) -> int:
"""
Returns a value such that for a list L, chunk count k and index i,
split(L, k)[i] == L[get_split_offset(len(L), k, i): get_split_offset(len(L), k, i+1)]
"""
return (list_size * index) // chunks
````
#### `get_shuffled_committee`
```python