From 6637ea09bf8e9ceda3d35a91c6695298720a4ba3 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 12 Jan 2021 10:37:22 +0200 Subject: [PATCH] fix isconnecting with ready status flag --- src/main/java/com/sparrowwallet/sparrow/net/Bwt.java | 7 +++++++ .../java/com/sparrowwallet/sparrow/net/ElectrumServer.java | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java b/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java index c88e1670..35399a2e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java @@ -26,6 +26,7 @@ public class Bwt { private static final int IMPORT_BATCH_SIZE = 350; private Long shutdownPtr; private boolean terminating; + private boolean ready; static { try { @@ -128,6 +129,7 @@ public class Bwt { } NativeBwtDaemon.shutdown(shutdownPtr); + this.ready = false; this.shutdownPtr = null; Platform.runLater(() -> EventManager.get().post(new BwtShutdownEvent())); } @@ -136,6 +138,10 @@ public class Bwt { return shutdownPtr != null; } + public boolean isReady() { + return ready; + } + public boolean isTerminating() { return terminating; } @@ -269,6 +275,7 @@ public class Bwt { @Override public void onReady() { log.debug("Bwt ready"); + ready = true; if(!terminating) { Platform.runLater(() -> EventManager.get().post(new BwtReadyStatusEvent("Server ready"))); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 128635cc..11037722 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -908,11 +908,11 @@ public class ElectrumServer { } public boolean isConnecting() { - return isRunning() && Config.get().getServerType() == ServerType.BITCOIN_CORE && !bwt.isRunning(); + return isRunning() && Config.get().getServerType() == ServerType.BITCOIN_CORE && bwt.isRunning() && !bwt.isReady(); } public boolean isConnected() { - return isRunning() && (Config.get().getServerType() != ServerType.BITCOIN_CORE || bwt.isRunning()); + return isRunning() && (Config.get().getServerType() != ServerType.BITCOIN_CORE || (bwt.isRunning() && bwt.isReady())); } @Override