3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 10:15:52 +00:00

WalletAppKit: Allow subclasses to fiddle with some more stuff.

This isn't really a stable or supportable API, but bitcoinj does not have a stable API, so live and let live.
This commit is contained in:
Mike Hearn 2014-01-15 21:26:53 +01:00
parent 80d4840199
commit ae1e3691f5

View File

@ -59,23 +59,23 @@ import static com.google.common.base.Preconditions.checkState;
* out what went wrong more precisely. Same thing if you use the async start() method.</p>
*/
public class WalletAppKit extends AbstractIdleService {
private final String filePrefix;
private final NetworkParameters params;
private volatile BlockChain vChain;
private volatile SPVBlockStore vStore;
private volatile Wallet vWallet;
private volatile PeerGroup vPeerGroup;
protected final String filePrefix;
protected final NetworkParameters params;
protected volatile BlockChain vChain;
protected volatile SPVBlockStore vStore;
protected volatile Wallet vWallet;
protected volatile PeerGroup vPeerGroup;
private final File directory;
private volatile File vWalletFile;
protected final File directory;
protected volatile File vWalletFile;
private boolean useAutoSave = true;
private PeerAddress[] peerAddresses;
private PeerEventListener downloadListener;
private boolean autoStop = true;
private InputStream checkpoints;
private boolean blockingStartup = true;
private String userAgent, version;
protected boolean useAutoSave = true;
protected PeerAddress[] peerAddresses;
protected PeerEventListener downloadListener;
protected boolean autoStop = true;
protected InputStream checkpoints;
protected boolean blockingStartup = true;
protected String userAgent, version;
public WalletAppKit(NetworkParameters params, File directory, String filePrefix) {
this.params = checkNotNull(params);
@ -199,7 +199,7 @@ public class WalletAppKit extends AbstractIdleService {
CheckpointManager.checkpoint(params, checkpoints, vStore, time);
}
vChain = new BlockChain(params, vStore);
vPeerGroup = new PeerGroup(params, vChain);
vPeerGroup = createPeerGroup();
if (this.userAgent != null)
vPeerGroup.setUserAgent(userAgent, version);
if (vWalletFile.exists()) {
@ -256,6 +256,10 @@ public class WalletAppKit extends AbstractIdleService {
}
}
protected PeerGroup createPeerGroup() {
return new PeerGroup(params, vChain);
}
private void installShutdownHook() {
if (autoStop) Runtime.getRuntime().addShutdownHook(new Thread() {
@Override public void run() {