improve ui with whirlpool startup errors

This commit is contained in:
Craig Raw 2021-10-14 13:35:17 +02:00
parent 23fd597ca5
commit 1b3a35fda7
3 changed files with 40 additions and 11 deletions

View file

@ -135,7 +135,13 @@ public class UtxosController extends WalletFormController implements Initializab
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet()); Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet());
if(whirlpool != null) { if(whirlpool != null) {
stopMix.visibleProperty().bind(whirlpool.mixingProperty()); stopMix.visibleProperty().bind(whirlpool.mixingProperty());
if(whirlpool.startingProperty().getValue()) {
mixingStartingListener.changed(whirlpool.startingProperty(), null, whirlpool.startingProperty().getValue());
}
whirlpool.startingProperty().addListener(new WeakChangeListener<>(mixingStartingListener)); whirlpool.startingProperty().addListener(new WeakChangeListener<>(mixingStartingListener));
if(whirlpool.stoppingProperty().getValue()) {
mixingStoppingListener.changed(whirlpool.stoppingProperty(), null, whirlpool.stoppingProperty().getValue());
}
whirlpool.stoppingProperty().addListener(new WeakChangeListener<>(mixingStoppingListener)); whirlpool.stoppingProperty().addListener(new WeakChangeListener<>(mixingStoppingListener));
whirlpool.mixingProperty().addListener(new WeakChangeListener<>(mixingListener)); whirlpool.mixingProperty().addListener(new WeakChangeListener<>(mixingListener));
updateMixToButton(); updateMixToButton();

View file

@ -373,6 +373,10 @@ public class Whirlpool {
config.setServerApi(serverApi); config.setServerApi(serverApi);
} }
public void refreshTorCircuits() {
torClientService.changeIdentity();
}
public String getScode() { public String getScode() {
return config.getScode(); return config.getScode();
} }
@ -578,14 +582,17 @@ public class Whirlpool {
updateProgress(-1, 1); updateProgress(-1, 1);
updateMessage("Starting Whirlpool..."); updateMessage("Starting Whirlpool...");
whirlpool.startingProperty.set(true); try {
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet(); whirlpool.startingProperty.set(true);
if(AppServices.onlineProperty().get()) { WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
whirlpoolWallet.start(); if(AppServices.onlineProperty().get()) {
} whirlpoolWallet.start();
whirlpool.startingProperty.set(false); }
return whirlpoolWallet; return whirlpoolWallet;
} finally {
whirlpool.startingProperty.set(false);
}
} }
}; };
} }
@ -604,10 +611,14 @@ public class Whirlpool {
protected Boolean call() throws Exception { protected Boolean call() throws Exception {
updateProgress(-1, 1); updateProgress(-1, 1);
updateMessage("Disconnecting from Whirlpool..."); updateMessage("Disconnecting from Whirlpool...");
whirlpool.stoppingProperty.set(true);
whirlpool.shutdown(); try {
whirlpool.stoppingProperty.set(false); whirlpool.stoppingProperty.set(true);
return true; whirlpool.shutdown();
return true;
} finally {
whirlpool.stoppingProperty.set(false);
}
} }
}; };
} }

View file

@ -19,10 +19,12 @@ import javafx.util.Duration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.SocketTimeoutException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class WhirlpoolServices { public class WhirlpoolServices {
@ -94,6 +96,16 @@ public class WhirlpoolServices {
}); });
startupService.setOnFailed(workerStateEvent -> { startupService.setOnFailed(workerStateEvent -> {
log.error("Failed to start whirlpool", workerStateEvent.getSource().getException()); log.error("Failed to start whirlpool", workerStateEvent.getSource().getException());
Throwable exception = workerStateEvent.getSource().getException();
while(exception.getCause() != null) {
exception = exception.getCause();
}
if(exception instanceof TimeoutException || exception instanceof SocketTimeoutException) {
EventManager.get().post(new StatusEvent("Error connecting to Whirlpool server, will retry soon..."));
if(torProxy != null) {
whirlpool.refreshTorCircuits();
}
}
}); });
startupService.start(); startupService.start();
} }