mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-20 22:38:11 +00:00
PR feedback from @mkalinin
This commit is contained in:
parent
e56bbb8c44
commit
28762096d3
@ -45,19 +45,15 @@ def get_pow_block_at_terminal_total_difficulty(pow_chain: Dict[Hash32, PowBlock]
|
||||
# `pow_chain` abstractly represents all blocks in the PoW chain
|
||||
for block in pow_chain.values():
|
||||
block_reached_ttd = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||||
# Genesis block
|
||||
if block.parent_hash == Hash32():
|
||||
# No parent exists, so reaching TTD alone qualifies as valid terminal block
|
||||
if block_reached_ttd:
|
||||
if block_reached_ttd:
|
||||
# If genesis block, no parent exists so reaching TTD alone qualifies as valid terminal block
|
||||
if block.parent_hash == Hash32():
|
||||
return block
|
||||
# Continue to iterate the next block
|
||||
if block.parent_hash not in pow_chain:
|
||||
continue
|
||||
|
||||
parent = pow_chain[block.parent_hash]
|
||||
parent_reached_ttd = parent.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||||
if block_reached_ttd and not parent_reached_ttd:
|
||||
return block
|
||||
else:
|
||||
parent = pow_chain[block.parent_hash]
|
||||
parent_reached_ttd = parent.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||||
if not parent_reached_ttd:
|
||||
return block
|
||||
|
||||
return None
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user