mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +00:00
improve ui with whirlpool startup errors
This commit is contained in:
parent
23fd597ca5
commit
1b3a35fda7
3 changed files with 40 additions and 11 deletions
|
@ -135,7 +135,13 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet());
|
||||
if(whirlpool != null) {
|
||||
stopMix.visibleProperty().bind(whirlpool.mixingProperty());
|
||||
if(whirlpool.startingProperty().getValue()) {
|
||||
mixingStartingListener.changed(whirlpool.startingProperty(), null, whirlpool.startingProperty().getValue());
|
||||
}
|
||||
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.mixingProperty().addListener(new WeakChangeListener<>(mixingListener));
|
||||
updateMixToButton();
|
||||
|
|
|
@ -373,6 +373,10 @@ public class Whirlpool {
|
|||
config.setServerApi(serverApi);
|
||||
}
|
||||
|
||||
public void refreshTorCircuits() {
|
||||
torClientService.changeIdentity();
|
||||
}
|
||||
|
||||
public String getScode() {
|
||||
return config.getScode();
|
||||
}
|
||||
|
@ -578,14 +582,17 @@ public class Whirlpool {
|
|||
updateProgress(-1, 1);
|
||||
updateMessage("Starting Whirlpool...");
|
||||
|
||||
whirlpool.startingProperty.set(true);
|
||||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
||||
if(AppServices.onlineProperty().get()) {
|
||||
whirlpoolWallet.start();
|
||||
}
|
||||
whirlpool.startingProperty.set(false);
|
||||
try {
|
||||
whirlpool.startingProperty.set(true);
|
||||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
||||
if(AppServices.onlineProperty().get()) {
|
||||
whirlpoolWallet.start();
|
||||
}
|
||||
|
||||
return whirlpoolWallet;
|
||||
return whirlpoolWallet;
|
||||
} finally {
|
||||
whirlpool.startingProperty.set(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -604,10 +611,14 @@ public class Whirlpool {
|
|||
protected Boolean call() throws Exception {
|
||||
updateProgress(-1, 1);
|
||||
updateMessage("Disconnecting from Whirlpool...");
|
||||
whirlpool.stoppingProperty.set(true);
|
||||
whirlpool.shutdown();
|
||||
whirlpool.stoppingProperty.set(false);
|
||||
return true;
|
||||
|
||||
try {
|
||||
whirlpool.stoppingProperty.set(true);
|
||||
whirlpool.shutdown();
|
||||
return true;
|
||||
} finally {
|
||||
whirlpool.stoppingProperty.set(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ import javafx.util.Duration;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WhirlpoolServices {
|
||||
|
@ -94,6 +96,16 @@ public class WhirlpoolServices {
|
|||
});
|
||||
startupService.setOnFailed(workerStateEvent -> {
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue