From 32ab53ba0302b71aeacca0920c5d5467b054dff3 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 8 Mar 2021 09:35:21 +0200 Subject: [PATCH] append tor debug output to test results --- .../ServerPreferencesController.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java index 3922fa3c..2a62c437 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java @@ -414,17 +414,15 @@ public class ServerPreferencesController extends PreferencesDetailController { torService.setPeriod(Duration.hours(1000)); torService.setRestartOnFailure(false); - torService.setOnRunning(workerStateEvent -> { - testResults.setText(testResults.getText() + "\nStarting Tor..."); - }); torService.setOnSucceeded(workerStateEvent -> { Tor.setDefault(torService.getValue()); torService.cancel(); - testResults.setText(testResults.getText() + "\nTor started"); + testResults.appendText("\nTor running, connecting to " + Config.get().getServerAddress() + "..."); startElectrumConnection(); }); torService.setOnFailed(workerStateEvent -> { - testResults.setText(testResults.getText() + "\nTor failed to start"); + torService.cancel(); + testResults.appendText("\nTor failed to start"); showConnectionFailure(workerStateEvent.getSource().getException()); }); @@ -766,4 +764,13 @@ public class ServerPreferencesController extends PreferencesDetailController { connectionService.cancel(); } } + + @Subscribe + public void torStatus(TorStatusEvent event) { + Platform.runLater(() -> { + if(torService != null && torService.isRunning()) { + testResults.appendText("\n" + event.getStatus()); + } + }); + } }