veriblock-core/src/main/java/org/veriblock/core/utilities/BlockUtility.java
/**
     * Determine whether a block header's PoW hash is below it's embedded difficulty.
     * NOTE: This method only ensures that the block is self-consistent, but not that it is at the appropriate difficulty
     * given the context of the blocks before it.
     * @param blockHeader Block header to calculate the PoW hash of and compare to it's embedded difficulty
     * @return Whether or not this block header's hash meets it's embedded difficulty
     */
Determine whether a block header's PoW hash is below it's embedded difficulty.
NOTE: This method only ensures that the block is self-consistent, but not that it is at the appropriate difficulty
given the context of the blocks before it.
@param blockHeader Block header to calculate the PoW hash of and compare to it's embedded difficulty
@return Whether or not this block header's hash meets it's embedded difficulty
Determine whether a block header ' s PoW hash is below it ' s embedded difficulty . NOTE : This method only ensures that the block is self - consistent but not that it is at the appropriate difficulty given the context of the blocks before it . @param blockHeader Block header to calculate the PoW hash of and compare to it ' s embedded difficulty @return Whether or not this block header ' s hash meets it ' s embedded difficulty
public static boolean isMinerHashBelowTarget(byte[] blockHeader) {
        Crypto crypto = new Crypto();
        String blockHash = crypto.vBlakeReturnHex(blockHeader);
        BigInteger difficulty = BitcoinUtilities.decodeCompactBits(extractDifficultyFromBlockHeader(blockHeader));
        if (difficulty.compareTo(BigInteger.ZERO) < 0 || !isEmbeddedDifficultyValid(difficulty) ) {
            return false;
        }
        BigInteger target = SharedConstants.DIFFICULTY_CALCULATOR_MAXIMUM_TARGET.divide(difficulty.multiply(BigInteger.valueOf(1)));
        boolean valid = new BigInteger(blockHash, 16).compareTo(target) < 0;
        return valid;
    }
public static boolean isMinerHashBelowTarget ( byte [ ] blockHeader ) { Crypto crypto = new Crypto ( ) ; String blockHash = crypto . vBlakeReturnHex ( blockHeader ) ; BigInteger difficulty = BitcoinUtilities . decodeCompactBits ( extractDifficultyFromBlockHeader ( blockHeader ) ) ; if ( difficulty . compareTo ( BigInteger . ZERO ) < 0 || ! isEmbeddedDifficultyValid ( difficulty ) ) { return false ; } BigInteger target = SharedConstants . DIFFICULTY_CALCULATOR_MAXIMUM_TARGET . divide ( difficulty . multiply ( BigInteger . valueOf ( 1 ) ) ) ; boolean valid = new BigInteger ( blockHash , 16 ) . compareTo ( target ) < 0 ; return valid ; }
Determine whether a block header's PoW hash is below it's embedded difficulty.
Determine whether a block header ' s PoW hash is below it ' s embedded difficulty .