Prevent connection to localhost bitcoin node if dao testnet is used (fix)

This commit is contained in:
Manfred Karrer 2019-02-21 12:25:48 -05:00
parent 518fe724d9
commit 0561c12a90
No known key found for this signature in database
GPG key ID: 401250966A6B2C46

View file

@ -209,9 +209,12 @@ public class WalletConfig extends AbstractIdleService {
}
private PeerGroup createPeerGroup() {
PeerGroup peerGroup;
// no proxy case.
if (socks5Proxy == null) {
return new PeerGroup(params, vChain);
peerGroup = new PeerGroup(params, vChain);
// For dao testnet (server side regtest) we prevent to connect to a localhost node to avoid confusion
// if local btc node is not synced with our dao testnet master node.
} else {
// proxy case (tor).
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
@ -224,10 +227,11 @@ public class WalletConfig extends AbstractIdleService {
new BlockingClientManager() :
new BlockingClientManager(proxySocketFactory);
PeerGroup peerGroup = new PeerGroup(params, vChain, blockingClientManager);
peerGroup = new PeerGroup(params, vChain, blockingClientManager);
blockingClientManager.setConnectTimeoutMillis(TIMEOUT);
peerGroup.setConnectTimeoutMillis(TIMEOUT);
}
// For dao testnet (server side regtest) we prevent to connect to a localhost node to avoid confusion
// if local btc node is not synced with our dao testnet master node.
@ -236,7 +240,6 @@ public class WalletConfig extends AbstractIdleService {
return peerGroup;
}
}
/**
* Will only connect to the given addresses. Cannot be called after startup.
@ -410,7 +413,7 @@ public class WalletConfig extends AbstractIdleService {
time = seed.getCreationTimeSeconds();
if (chainFileExists) {
log.info("Clearing the chain file in preparation from restore.");
((ClearableSPVBlockStore)vStore).clear();
((ClearableSPVBlockStore) vStore).clear();
}
} else {
time = vBtcWallet.getEarliestKeyCreationTime();
@ -423,7 +426,7 @@ public class WalletConfig extends AbstractIdleService {
log.warn("Creating a new uncheckpointed block store due to a wallet with a creation time of zero: this will result in a very slow chain sync");
} else if (chainFileExists) {
log.info("Clearing the chain file in preparation from restore.");
((ClearableSPVBlockStore)vStore).clear();
((ClearableSPVBlockStore) vStore).clear();
}
}
vChain = new BlockChain(params, vStore);