3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

WalletAppKit: Fix stupid ordering bug I introduced that affects apps that use payment channels.

In future, this stuff should probably be enabled in the wallet by default.
This commit is contained in:
Mike Hearn 2013-09-21 19:53:52 +02:00
parent 1f52b75ad9
commit c861ecdf2a

View File

@ -168,6 +168,12 @@ public class WalletAppKit extends AbstractIdleService {
try {
File chainFile = new File(directory, filePrefix + ".spvchain");
boolean chainFileExists = chainFile.exists();
vStore = new SPVBlockStore(params, chainFile);
if (!chainFileExists && checkpoints != null) {
CheckpointManager.checkpoint(params, checkpoints, vStore, vWallet.getEarliestKeyCreationTime());
}
vChain = new BlockChain(params, vStore);
vPeerGroup = new PeerGroup(params, vChain);
vWalletFile = new File(directory, filePrefix + ".wallet");
boolean shouldReplayWallet = vWalletFile.exists() && !chainFileExists;
if (vWalletFile.exists()) {
@ -183,12 +189,6 @@ public class WalletAppKit extends AbstractIdleService {
addWalletExtensions();
}
if (useAutoSave) vWallet.autosaveToFile(vWalletFile, 1, TimeUnit.SECONDS, null);
vStore = new SPVBlockStore(params, chainFile);
if (!chainFileExists && checkpoints != null) {
CheckpointManager.checkpoint(params, checkpoints, vStore, vWallet.getEarliestKeyCreationTime());
}
vChain = new BlockChain(params, vStore);
vPeerGroup = new PeerGroup(params, vChain);
// Set up peer addresses or discovery first, so if wallet extensions try to broadcast a transaction
// before we're actually connected the broadcast waits for an appropriate number of connections.
if (peerAddresses != null) {