mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-20 15:38:55 +00:00
Compute epoch only once for better readability
This commit is contained in:
parent
4df86632b6
commit
e67ca3d309
@ -34,7 +34,9 @@ def compute_merkle_proof_for_block_body(body: BeaconBlockBody,
|
||||
|
||||
```python
|
||||
def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
|
||||
if compute_epoch_at_slot(block.message.slot) >= CAPELLA_FORK_EPOCH:
|
||||
epoch = compute_epoch_at_slot(block.message.slot)
|
||||
|
||||
if epoch >= CAPELLA_FORK_EPOCH:
|
||||
payload = block.message.body.execution_payload
|
||||
execution_header = ExecutionPayloadHeader(
|
||||
parent_hash=payload.parent_hash,
|
||||
|
@ -152,7 +152,9 @@ def get_lc_beacon_root(header: LightClientHeader) -> Root:
|
||||
|
||||
```python
|
||||
def get_lc_execution_root(header: LightClientHeader) -> Root:
|
||||
if compute_epoch_at_slot(get_lc_beacon_slot(header)) >= CAPELLA_FORK_EPOCH:
|
||||
epoch = compute_epoch_at_slot(get_lc_beacon_slot(header))
|
||||
|
||||
if epoch >= CAPELLA_FORK_EPOCH:
|
||||
return hash_tree_root(header.execution)
|
||||
|
||||
return Root()
|
||||
@ -162,7 +164,9 @@ def get_lc_execution_root(header: LightClientHeader) -> Root:
|
||||
|
||||
```python
|
||||
def is_valid_light_client_header(header: LightClientHeader) -> bool:
|
||||
if compute_epoch_at_slot(get_lc_beacon_slot(header)) < CAPELLA_FORK_EPOCH:
|
||||
epoch = compute_epoch_at_slot(get_lc_beacon_slot(header))
|
||||
|
||||
if epoch < CAPELLA_FORK_EPOCH:
|
||||
if header.execution != ExecutionPayloadHeader():
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user