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:
parent
9639b45ad8
commit
a54e2e96eb
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user