PeerGroup: Fix NullPointerException in handleNewPeer() if no download peer could be selected.

This commit is contained in:
Andreas Schildbach
2019-01-31 18:17:30 +01:00
parent 5d6ae4082b
commit e3e4e3f32a

View File

@@ -1515,11 +1515,14 @@ public class PeerGroup implements TransactionBroadcaster {
for (Wallet wallet : wallets) for (Wallet wallet : wallets)
peer.addWallet(wallet); peer.addWallet(wallet);
if (downloadPeer == null) { if (downloadPeer == null) {
// Kick off chain download if we aren't already doing it. Peer newDownloadPeer = selectDownloadPeer(peers);
setDownloadPeer(selectDownloadPeer(peers)); if (newDownloadPeer != null) {
boolean shouldDownloadChain = downloadListener != null && chain != null; setDownloadPeer(newDownloadPeer);
if (shouldDownloadChain) { // Kick off chain download if we aren't already doing it.
startBlockChainDownloadFromPeer(downloadPeer); boolean shouldDownloadChain = downloadListener != null && chain != null;
if (shouldDownloadChain) {
startBlockChainDownloadFromPeer(downloadPeer);
}
} }
} }
// Make sure the peer knows how to upload transactions that are requested from us. // Make sure the peer knows how to upload transactions that are requested from us.