mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
clear transport on a failed test connection, try ssl or vice-versa on electrum connection failure
This commit is contained in:
parent
a801773545
commit
0f639dc2c2
1 changed files with 27 additions and 0 deletions
|
@ -149,6 +149,8 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
||||||
|
|
||||||
private ElectrumServer.ConnectionService connectionService;
|
private ElectrumServer.ConnectionService connectionService;
|
||||||
|
|
||||||
|
private Boolean useSslOriginal;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeView(Config config) {
|
public void initializeView(Config config) {
|
||||||
EventManager.get().register(this);
|
EventManager.get().register(this);
|
||||||
|
@ -439,6 +441,8 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
||||||
connectionService.setRestartOnFailure(false);
|
connectionService.setRestartOnFailure(false);
|
||||||
EventManager.get().register(connectionService);
|
EventManager.get().register(connectionService);
|
||||||
|
|
||||||
|
useSslOriginal = null;
|
||||||
|
|
||||||
connectionService.setOnSucceeded(successEvent -> {
|
connectionService.setOnSucceeded(successEvent -> {
|
||||||
EventManager.get().unregister(connectionService);
|
EventManager.get().unregister(connectionService);
|
||||||
ConnectionEvent connectionEvent = (ConnectionEvent)connectionService.getValue();
|
ConnectionEvent connectionEvent = (ConnectionEvent)connectionService.getValue();
|
||||||
|
@ -450,6 +454,29 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
||||||
connectionService.setOnFailed(workerStateEvent -> {
|
connectionService.setOnFailed(workerStateEvent -> {
|
||||||
EventManager.get().unregister(connectionService);
|
EventManager.get().unregister(connectionService);
|
||||||
showConnectionFailure(workerStateEvent.getSource().getException());
|
showConnectionFailure(workerStateEvent.getSource().getException());
|
||||||
|
connectionService.cancel();
|
||||||
|
|
||||||
|
if(Config.get().getServerType() == ServerType.ELECTRUM_SERVER) {
|
||||||
|
if(useSslOriginal == null) {
|
||||||
|
Integer portAsInteger = getPort(electrumPort.getText());
|
||||||
|
if(!electrumUseSsl.isSelected() && portAsInteger != null && portAsInteger == TcpOverTlsTransport.DEFAULT_PORT) {
|
||||||
|
useSslOriginal = false;
|
||||||
|
electrumUseSsl.setSelected(true);
|
||||||
|
} else if(electrumUseSsl.isSelected() && portAsInteger != null && portAsInteger == TcpTransport.DEFAULT_PORT) {
|
||||||
|
useSslOriginal = true;
|
||||||
|
electrumUseSsl.setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(useSslOriginal != null) {
|
||||||
|
EventManager.get().register(connectionService);
|
||||||
|
connectionService.reset();
|
||||||
|
connectionService.start();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
electrumUseSsl.setSelected(useSslOriginal);
|
||||||
|
useSslOriginal = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connectionService.start();
|
connectionService.start();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue