mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
c8748260fd
* add validator terminal block difficulties * Fix test Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
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
|
|
}
|