mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-23 14:40:40 +01:00
BitcoinNetworkParams: improve logging if max difficulty target has been hit
This commit is contained in:
parent
c60c612107
commit
318ead0a74
1 changed files with 6 additions and 3 deletions
|
@ -211,9 +211,12 @@ public abstract class BitcoinNetworkParams extends NetworkParameters {
|
||||||
newTarget = newTarget.multiply(BigInteger.valueOf(timespan));
|
newTarget = newTarget.multiply(BigInteger.valueOf(timespan));
|
||||||
newTarget = newTarget.divide(BigInteger.valueOf(targetTimespan));
|
newTarget = newTarget.divide(BigInteger.valueOf(targetTimespan));
|
||||||
|
|
||||||
if (newTarget.compareTo(this.getMaxTarget()) > 0) {
|
BigInteger maxTarget = this.getMaxTarget();
|
||||||
log.info("Difficulty hit proof of work limit: {}", newTarget.toString(16));
|
if (newTarget.compareTo(maxTarget) > 0) {
|
||||||
newTarget = this.getMaxTarget();
|
log.info("Difficulty hit proof of work limit: {} vs {}",
|
||||||
|
Long.toHexString(ByteUtils.encodeCompactBits(newTarget)),
|
||||||
|
Long.toHexString(ByteUtils.encodeCompactBits(maxTarget)));
|
||||||
|
newTarget = maxTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
int accuracyBytes = (int) (nextBlock.getDifficultyTarget() >>> 24) - 3;
|
int accuracyBytes = (int) (nextBlock.getDifficultyTarget() >>> 24) - 3;
|
||||||
|
|
Loading…
Add table
Reference in a new issue