|
|
@ -14,6 +14,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; |
|
|
|
package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.config.MergeConfigOptions; |
|
|
|
import org.hyperledger.besu.ethereum.ProtocolContext; |
|
|
|
import org.hyperledger.besu.ethereum.ProtocolContext; |
|
|
|
import org.hyperledger.besu.ethereum.core.BlockHeader; |
|
|
|
import org.hyperledger.besu.ethereum.core.BlockHeader; |
|
|
|
import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; |
|
|
|
import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; |
|
|
@ -36,7 +37,9 @@ public class CalculatedDifficultyValidationRule implements AttachedBlockHeaderVa |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean validate( |
|
|
|
public boolean validate( |
|
|
|
final BlockHeader header, final BlockHeader parent, final ProtocolContext context) { |
|
|
|
final BlockHeader header, final BlockHeader parent, final ProtocolContext context) { |
|
|
|
|
|
|
|
if (MergeConfigOptions.isMergeEnabled()) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
final BigInteger actualDifficulty = new BigInteger(1, header.getDifficulty().toArray()); |
|
|
|
final BigInteger actualDifficulty = new BigInteger(1, header.getDifficulty().toArray()); |
|
|
|
final BigInteger expectedDifficulty = |
|
|
|
final BigInteger expectedDifficulty = |
|
|
|
difficultyCalculator.nextDifficulty(header.getTimestamp(), parent, context); |
|
|
|
difficultyCalculator.nextDifficulty(header.getTimestamp(), parent, context); |
|
|
|