From 34b79e779b565d2102a4f32210658aea5c83217a Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 26 Feb 2023 15:24:43 -0500 Subject: [PATCH] remove extraneous errors on daemon disconnect, one warning per 5 minutes --- .../core/api/CoreMoneroConnectionsService.java | 13 +++++++++++-- .../bisq/core/btc/wallet/XmrWalletService.java | 2 +- core/src/main/java/bisq/core/trade/Trade.java | 16 +++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreMoneroConnectionsService.java b/core/src/main/java/bisq/core/api/CoreMoneroConnectionsService.java index 6d9479e5..8bbdea09 100644 --- a/core/src/main/java/bisq/core/api/CoreMoneroConnectionsService.java +++ b/core/src/main/java/bisq/core/api/CoreMoneroConnectionsService.java @@ -42,6 +42,8 @@ public final class CoreMoneroConnectionsService { private static final int MIN_BROADCAST_CONNECTIONS = 0; // TODO: 0 for stagenet, 5+ for mainnet private static final long REFRESH_PERIOD_LOCAL_MS = 5000; // refresh period when connected to local node private static final long REFRESH_PERIOD_REMOTE_MS = 20000; // refresh period when connected to remote node + private static final long MIN_ERROR_LOG_PERIOD_MS = 300000; // minimum period between logging errors fetching daemon info + private static Long lastErrorTimestamp; // default Monero nodes private static final Map> DEFAULT_CONNECTIONS; @@ -441,9 +443,16 @@ public final class CoreMoneroConnectionsService { peers.set(new ArrayList()); // TODO: peers unknown due to restricted RPC call } numPeers.set(peers.get().size()); + if (lastErrorTimestamp != null) { + log.info("Successfully fetched daemon info after previous error"); + lastErrorTimestamp = null; + } } catch (Exception e) { - log.warn("Could not update daemon info: " + e.getMessage()); - if (DevEnv.isDevMode()) e.printStackTrace(); + if (lastErrorTimestamp == null || System.currentTimeMillis() - lastErrorTimestamp > MIN_ERROR_LOG_PERIOD_MS) { + lastErrorTimestamp = System.currentTimeMillis(); + log.warn("Could not update daemon info: " + e.getMessage()); + if (DevEnv.isDevMode()) e.printStackTrace(); + } if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection()); } } diff --git a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java index 0974082f..178150c5 100644 --- a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java @@ -677,7 +677,7 @@ public class XmrWalletService { if (wallet == null) maybeInitMainWallet(); else { wallet.setDaemonConnection(connection); - if (connection != null) new Thread(() -> trySyncMainWallet()).start(); + if (connection != null && !Boolean.FALSE.equals(connection.isConnected())) new Thread(() -> trySyncMainWallet()).start(); } } diff --git a/core/src/main/java/bisq/core/trade/Trade.java b/core/src/main/java/bisq/core/trade/Trade.java index 9bc2522e..4f6aff43 100644 --- a/core/src/main/java/bisq/core/trade/Trade.java +++ b/core/src/main/java/bisq/core/trade/Trade.java @@ -1648,13 +1648,15 @@ public abstract class Trade implements Tradable, Model { wallet.setDaemonConnection(connection); // sync and reprocess messages on new thread - HavenoUtils.submitTask(() -> { - updateSyncing(); - - // reprocess pending payout messages - this.getProtocol().maybeReprocessPaymentReceivedMessage(false); - HavenoUtils.arbitrationManager.maybeReprocessDisputeClosedMessage(this, false); - }); + if (connection != null && !Boolean.FALSE.equals(connection.isConnected())) { + HavenoUtils.submitTask(() -> { + updateSyncing(); + + // reprocess pending payout messages + this.getProtocol().maybeReprocessPaymentReceivedMessage(false); + HavenoUtils.arbitrationManager.maybeReprocessDisputeClosedMessage(this, false); + }); + } } private void updateSyncing() {