mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
WalletAppKit: allow customisation of the peer discovery engine.
This commit is contained in:
parent
211966b17b
commit
483f9b50e6
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.*;
|
||||
import com.subgraph.orchid.TorClient;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.net.discovery.DnsDiscovery;
|
||||
import org.bitcoinj.net.discovery.PeerDiscovery;
|
||||
import org.bitcoinj.protocols.channels.StoredPaymentChannelClientStates;
|
||||
import org.bitcoinj.protocols.channels.StoredPaymentChannelServerStates;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
@ -90,6 +91,7 @@ public class WalletAppKit extends AbstractIdleService {
|
||||
protected String userAgent, version;
|
||||
protected WalletProtobufSerializer.WalletFactory walletFactory;
|
||||
@Nullable protected DeterministicSeed restoreFromSeed;
|
||||
@Nullable protected PeerDiscovery discovery;
|
||||
|
||||
public WalletAppKit(NetworkParameters params, File directory, String filePrefix) {
|
||||
this.params = checkNotNull(params);
|
||||
@ -198,6 +200,14 @@ public class WalletAppKit extends AbstractIdleService {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the peer discovery class to use. If none is provided then DNS is used, which is a reasonable default.
|
||||
*/
|
||||
public WalletAppKit setDiscovery(@Nullable PeerDiscovery discovery) {
|
||||
this.discovery = discovery;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Override this to return wallet extensions if any are necessary.</p>
|
||||
*
|
||||
@ -292,7 +302,7 @@ public class WalletAppKit extends AbstractIdleService {
|
||||
vPeerGroup.setMaxConnections(peerAddresses.length);
|
||||
peerAddresses = null;
|
||||
} else {
|
||||
vPeerGroup.addPeerDiscovery(new DnsDiscovery(params));
|
||||
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
|
||||
}
|
||||
vChain.addWallet(vWallet);
|
||||
vPeerGroup.addWallet(vWallet);
|
||||
|
Loading…
x
Reference in New Issue
Block a user