mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +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());
|
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();
|
||||||
|
|
|
@ -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...");
|
||||||
|
|
||||||
|
try {
|
||||||
whirlpool.startingProperty.set(true);
|
whirlpool.startingProperty.set(true);
|
||||||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
||||||
if(AppServices.onlineProperty().get()) {
|
if(AppServices.onlineProperty().get()) {
|
||||||
whirlpoolWallet.start();
|
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...");
|
||||||
|
|
||||||
|
try {
|
||||||
whirlpool.stoppingProperty.set(true);
|
whirlpool.stoppingProperty.set(true);
|
||||||
whirlpool.shutdown();
|
whirlpool.shutdown();
|
||||||
whirlpool.stoppingProperty.set(false);
|
|
||||||
return true;
|
return true;
|
||||||
|
} finally {
|
||||||
|
whirlpool.stoppingProperty.set(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue