use of bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow in project bisq-desktop by bisq-network.
the class MainViewModel method startBasicServices.
private void startBasicServices() {
log.info("startBasicServices");
ChangeListener<Boolean> walletInitializedListener = (observable, oldValue, newValue) -> {
// TODO that seems to be called too often if Tor takes longer to start up...
if (newValue && !p2pNetWorkReady.get())
showTorNetworkSettingsWindow();
};
Timer startupTimeout = UserThread.runAfter(() -> {
log.warn("startupTimeout called");
if (walletsManager.areWalletsEncrypted())
walletInitialized.addListener(walletInitializedListener);
else
showTorNetworkSettingsWindow();
}, STARTUP_TIMEOUT_MINUTES, TimeUnit.MINUTES);
p2pNetWorkReady = initP2PNetwork();
// When using Tor, wallet init must be deferred until Tor is ready.
if (!preferences.getUseTorForBitcoinJ() || bisqEnvironment.isBitcoinLocalhostNodeRunning())
initWalletService();
// need to store it to not get garbage collected
allServicesDone = EasyBind.combine(walletInitialized, p2pNetWorkReady, (a, b) -> {
log.debug("\nwalletInitialized={}\n" + "p2pNetWorkReady={}", a, b);
return a && b;
});
allServicesDone.subscribe((observable, oldValue, newValue) -> {
if (newValue) {
startupTimeout.stop();
walletInitialized.removeListener(walletInitializedListener);
onBasicServicesInitialized();
if (torNetworkSettingsWindow != null)
torNetworkSettingsWindow.hide();
}
});
}
Aggregations