Block { public byte[] calcDifficulty() { if (!parsed) parseRLP(); return this.header.calcDifficulty(); } Block(byte[] rawData);  Block(byte[] parentHash, byte[] unclesHash, byte[] coinbase,
			byte[] difficulty, long number, long minGasPrice, long gasLimit,
			long gasUsed, long timestamp, byte[] extraData, byte[] nonce,
			List<Transaction> transactionsList, List<BlockHeader> uncleList); byte[] getHash(); Block getParent(); byte[] calcDifficulty(); long calcGasLimit(); boolean validateNonce(); byte[] getParentHash(); byte[] getUnclesHash(); byte[] getCoinbase(); byte[] getStateRoot(); void setStateRoot(byte[] stateRoot); byte[] getTxTrieRoot(); byte[] getDifficulty(); BigInteger getCumulativeDifficulty(); long getTimestamp(); long getNumber(); long getMinGasPrice(); long getGasLimit(); long getGasUsed(); byte[] getExtraData(); byte[] getNonce(); void setNonce(byte[] nonce); List<Transaction> getTransactionsList(); List<TransactionReceipt> getTxReceiptList(); List<BlockHeader> getUncleList(); @Override String toString(); String toFlatString(); String toStylishString(); boolean isValid(); boolean isGenesis(); byte[] getEncoded(); byte[] getEncodedWithoutNonce(); static BigInteger BLOCK_REWARD; static BigInteger UNCLE_REWARD; static BigInteger INCLUSION_REWARD; }
@Test public void testCalcDifficulty() { Block genesis = Genesis.getInstance(); BigInteger difficulty = new BigInteger(1, genesis.calcDifficulty()); System.out.println("Genesis difficulty = " + difficulty.toString()); assertEquals(new BigInteger(1, Genesis.DIFFICULTY), difficulty); WorldManager.getInstance().getBlockchain().add(genesis); Block block1 = new Block(Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED)); BigInteger calcDifficulty = new BigInteger(1, block1.calcDifficulty()); BigInteger actualDifficulty = new BigInteger(1, block1.getDifficulty()); System.out.println("Block#1 actual difficulty = " + actualDifficulty.toString()); System.out.println("Block#1 calculated difficulty = " + calcDifficulty.toString()); assertEquals(actualDifficulty, calcDifficulty); }