mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
20 lines
899 B
Go
20 lines
899 B
Go
|
package blockchain
|
||
|
|
||
|
import (
|
||
|
"github.com/holiman/uint256"
|
||
|
"github.com/prysmaticlabs/prysm/config/params"
|
||
|
)
|
||
|
|
||
|
// validates terminal pow block by comparing own total difficulty with parent's total difficulty.
|
||
|
//
|
||
|
// def is_valid_terminal_pow_block(block: PowBlock, parent: PowBlock) -> bool:
|
||
|
// is_total_difficulty_reached = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||
|
// is_parent_total_difficulty_valid = parent.total_difficulty < TERMINAL_TOTAL_DIFFICULTY
|
||
|
// return is_total_difficulty_reached and is_parent_total_difficulty_valid
|
||
|
func validTerminalPowBlock(currentDifficulty *uint256.Int, parentDifficulty *uint256.Int) bool {
|
||
|
ttd := uint256.NewInt(params.BeaconConfig().TerminalTotalDifficulty)
|
||
|
totalDifficultyReached := currentDifficulty.Cmp(ttd) >= 0
|
||
|
parentTotalDifficultyValid := ttd.Cmp(parentDifficulty) > 0
|
||
|
return totalDifficultyReached && parentTotalDifficultyValid
|
||
|
}
|