mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 19:54:34 +00:00
use helper for slots since epoch start
This commit is contained in:
parent
fc40bff2a8
commit
09fd49ce89
@ -96,11 +96,20 @@ def get_genesis_store(genesis_state: BeaconState) -> Store:
|
||||
)
|
||||
```
|
||||
|
||||
#### `get_current_slot`
|
||||
|
||||
```python
|
||||
def get_current_slot(store: Store) -> Slot:
|
||||
return Slot((store.time - store.genesis_time) // SECONDS_PER_SLOT)
|
||||
```
|
||||
|
||||
#### `compute_slots_since_epoch_start`
|
||||
|
||||
```python
|
||||
def compute_slots_since_epoch_start(slot: Slot) -> int:
|
||||
return slot - compute_start_slot_at_epoch(compute_epoch_at_slot(slot))
|
||||
```
|
||||
|
||||
#### `get_ancestor`
|
||||
|
||||
```python
|
||||
@ -149,7 +158,7 @@ def get_head(store: Store) -> Hash:
|
||||
|
||||
```python
|
||||
def should_update_justified_checkpoint(store: Store, new_justified_checkpoint: Checkpoint) -> bool:
|
||||
if get_current_slot(store) % SLOTS_PER_EPOCH < SAFE_SLOTS_TO_UPDATE_JUSTIFIED:
|
||||
if compute_slots_since_epoch_start(get_current_slot(store)) < SAFE_SLOTS_TO_UPDATE_JUSTIFIED:
|
||||
return True
|
||||
|
||||
new_justified_block = store.blocks[new_justified_checkpoint.root]
|
||||
|
Loading…
x
Reference in New Issue
Block a user