3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Fix NullPointerException if using chain == null in PeerGroup

This commit is contained in:
Matt Corallo 2012-11-24 01:02:49 -05:00 committed by Mike Hearn
parent 0208b426f5
commit 44865a3c50

View File

@ -533,7 +533,7 @@ public class PeerGroup extends AbstractIdleService {
private synchronized void recalculateFastCatchupTime() { private synchronized void recalculateFastCatchupTime() {
// Fully verifying mode doesn't use this optimization (it can't as it needs to see all transactions). // Fully verifying mode doesn't use this optimization (it can't as it needs to see all transactions).
if (chain.shouldVerifyTransactions()) return; if (chain != null && chain.shouldVerifyTransactions()) return;
long earliestKeyTime = Long.MAX_VALUE; long earliestKeyTime = Long.MAX_VALUE;
for (Wallet w : wallets) { for (Wallet w : wallets) {
earliestKeyTime = Math.min(earliestKeyTime, w.getEarliestKeyCreationTime()); earliestKeyTime = Math.min(earliestKeyTime, w.getEarliestKeyCreationTime());
@ -786,7 +786,7 @@ public class PeerGroup extends AbstractIdleService {
* {@link Peer#setFastCatchupTime(long)} for further explanation. Call this before starting block chain download. * {@link Peer#setFastCatchupTime(long)} for further explanation. Call this before starting block chain download.
*/ */
public synchronized void setFastCatchupTimeSecs(long secondsSinceEpoch) { public synchronized void setFastCatchupTimeSecs(long secondsSinceEpoch) {
Preconditions.checkState(!chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying"); Preconditions.checkState(chain == null || !chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying");
fastCatchupTimeSecs = secondsSinceEpoch; fastCatchupTimeSecs = secondsSinceEpoch;
if (downloadPeer != null) { if (downloadPeer != null) {
downloadPeer.setFastCatchupTime(secondsSinceEpoch); downloadPeer.setFastCatchupTime(secondsSinceEpoch);