3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 06:44:16 +00:00

Fix a bug in difficulty calculation logic that is revealed by testnet3. It should not impact the main net. Resolves issue 262. Rethrow block verification errors with a message containing the block.

This commit is contained in:
Mike Hearn 2012-12-24 16:12:13 +00:00
parent 9639b45ad8
commit a54e2e96eb

View File

@ -188,7 +188,8 @@ public abstract class AbstractBlockChain {
} catch (BlockStoreException e1) {
throw new RuntimeException(e1);
}
throw e;
throw new VerificationException("Could not verify block " + block.getHashAsString() + "\n" +
block.toString(), e);
}
}
@ -672,7 +673,7 @@ public abstract class AbstractBlockChain {
if (timespan > params.targetTimespan * 4)
timespan = params.targetTimespan * 4;
BigInteger newDifficulty = Utils.decodeCompactBits(blockIntervalAgo.getDifficultyTarget());
BigInteger newDifficulty = Utils.decodeCompactBits(prev.getDifficultyTarget());
newDifficulty = newDifficulty.multiply(BigInteger.valueOf(timespan));
newDifficulty = newDifficulty.divide(BigInteger.valueOf(params.targetTimespan));