mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
WalletAppKit: Configure the peergroup with candidate peers before adding wallet extensions, as payment channel state can attempt to broadcast a transaction as soon as the state is loaded/instantiated. This ensures the number of min peers required for broadcast is correct at that point.
This commit is contained in:
parent
a1daaa73be
commit
2a635317c3
@ -98,7 +98,14 @@ public class WalletAppKit extends AbstractIdleService {
|
||||
vStore = new SPVBlockStore(params, vChainFile);
|
||||
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 (vPeerAddresses != null) {
|
||||
for (PeerAddress addr : vPeerAddresses) vPeerGroup.addAddress(addr);
|
||||
vPeerAddresses = null;
|
||||
} else {
|
||||
vPeerGroup.addPeerDiscovery(new DnsDiscovery(params));
|
||||
}
|
||||
if (vWalletFile.exists()) {
|
||||
walletStream = new FileInputStream(vWalletFile);
|
||||
vWallet = new Wallet(params);
|
||||
@ -113,12 +120,6 @@ public class WalletAppKit extends AbstractIdleService {
|
||||
if (vUseAutoSave) vWallet.autosaveToFile(vWalletFile, 1, TimeUnit.SECONDS, null);
|
||||
vChain.addWallet(vWallet);
|
||||
vPeerGroup.addWallet(vWallet);
|
||||
if (vPeerAddresses != null) {
|
||||
for (PeerAddress addr : vPeerAddresses) vPeerGroup.addAddress(addr);
|
||||
vPeerAddresses = null;
|
||||
} else {
|
||||
vPeerGroup.addPeerDiscovery(new DnsDiscovery(params));
|
||||
}
|
||||
vPeerGroup.startAndWait();
|
||||
vPeerGroup.downloadBlockChain();
|
||||
// Make sure we shut down cleanly.
|
||||
|
Loading…
Reference in New Issue
Block a user