3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 18:25:51 +00:00

AbstractBitcoinNetParams.checkDifficultyTransitions: Check we're really on a transition point after finding the way back to the last one.

This commit is contained in:
Andreas Schildbach 2016-08-24 14:24:58 +02:00 committed by Andreas Schildbach
parent eccf14adeb
commit c6418dc06d

View File

@ -17,6 +17,8 @@
package org.bitcoinj.params;
import static com.google.common.base.Preconditions.checkState;
import java.math.BigInteger;
import java.util.concurrent.TimeUnit;
@ -104,6 +106,8 @@ public abstract class AbstractBitcoinNetParams extends NetworkParameters {
}
hash = cursor.getHeader().getPrevBlockHash();
}
checkState(cursor != null && isDifficultyTransitionPoint(cursor.getHeight() - 1),
"Didn't arrive at a transition point.");
watch.stop();
if (watch.elapsed(TimeUnit.MILLISECONDS) > 50)
log.info("Difficulty transition traversal took {}", watch);