mirror of https://github.com/status-im/op-geth.git
parent
24613a60dc
commit
7394ee7c72
|
@ -242,8 +242,7 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
expd := CalcDifficulty(block, parent)
|
expd := CalcDifficulty(block, parent)
|
||||||
if expd.Cmp(block.Header().Difficulty) < 0 {
|
if expd.Cmp(block.Header().Difficulty) != 0 {
|
||||||
fmt.Println("parent\n", parent)
|
|
||||||
return fmt.Errorf("Difficulty check failed for block %v, %v", block.Header().Difficulty, expd)
|
return fmt.Errorf("Difficulty check failed for block %v, %v", block.Header().Difficulty, expd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,11 @@ type StateQuery interface {
|
||||||
func CalcDifficulty(block, parent *types.Block) *big.Int {
|
func CalcDifficulty(block, parent *types.Block) *big.Int {
|
||||||
diff := new(big.Int)
|
diff := new(big.Int)
|
||||||
|
|
||||||
bh, ph := block.Header(), parent.Header()
|
adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
|
||||||
adjust := new(big.Int).Rsh(ph.Difficulty, 10)
|
if block.Time() >= parent.Time()+8 {
|
||||||
if bh.Time >= ph.Time+13 {
|
diff.Sub(parent.Difficulty(), adjust)
|
||||||
diff.Sub(ph.Difficulty, adjust)
|
|
||||||
} else {
|
} else {
|
||||||
diff.Add(ph.Difficulty, adjust)
|
diff.Add(parent.Difficulty(), adjust)
|
||||||
}
|
}
|
||||||
|
|
||||||
return diff
|
return diff
|
||||||
|
|
Loading…
Reference in New Issue