From e39a2cb944649b2401bd63c325bf06a9d91a621d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 17 Nov 2022 08:08:50 +0200 Subject: [PATCH] fix isconnecting state change --- src/main/java/com/sparrowwallet/sparrow/AppServices.java | 2 +- .../com/sparrowwallet/sparrow/net/ElectrumServer.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 9a58d3be..644c11db 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -284,7 +284,7 @@ public class AppServices { }); connectionService.setOnFailed(failEvent -> { //Close connection here to create a new transport next time we try - connectionService.resetConnection(); + connectionService.closeConnection(); if(failEvent.getSource().getException() instanceof ServerConfigException) { connectionService.setRestartOnFailure(false); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index dddfeb6c..c69cb195 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -1176,7 +1176,7 @@ public class ElectrumServer { return new FeeRatesUpdatedEvent(blockTargetFeeRates, mempoolRateSizes); } } else { - resetConnection(); + closeConnection(); } } @@ -1185,18 +1185,18 @@ public class ElectrumServer { }; } - public void resetConnection() { + public void closeConnection() { try { closeActiveConnection(); shutdown(); firstCall = true; } catch (ServerException e) { - log.error("Error closing connection during connection reset", e); + log.error("Error closing connection", e); } } public boolean isConnecting() { - return isRunning() && firstCall && (Config.get().getServerType() != ServerType.BITCOIN_CORE || (bwt.isRunning() && !bwt.isReady())); + return isRunning() && firstCall && !shutdown && (Config.get().getServerType() != ServerType.BITCOIN_CORE || (bwt.isRunning() && !bwt.isReady())); } public boolean isConnectionRunning() { @@ -1250,6 +1250,7 @@ public class ElectrumServer { public void reset() { super.reset(); firstCall = true; + shutdown = false; } @Override