From 58cead603548e085fc2371e78bbb72ec6d5ff54b Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 16 May 2024 10:24:00 -0400 Subject: [PATCH] do not log error polling wallet within 3m of success --- .../java/haveno/core/api/XmrConnectionService.java | 4 ++-- .../java/haveno/core/xmr/wallet/XmrWalletService.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index 93f95d9a05..b0e1a96247 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -65,7 +65,7 @@ public final class XmrConnectionService { private static final int MIN_BROADCAST_CONNECTIONS = 0; // TODO: 0 for stagenet, 5+ for mainnet private static final long REFRESH_PERIOD_HTTP_MS = 20000; // refresh period when connected to remote node over http private static final long REFRESH_PERIOD_ONION_MS = 30000; // refresh period when connected to remote node over tor - private static final long MIN_ERROR_LOG_PERIOD_MS = 300000; // minimum period between logging errors fetching daemon info + private static final long LOG_POLL_ERROR_AFTER_MS = 300000; // minimum period between logging errors fetching daemon info private static Long lastErrorTimestamp; private final Object lock = new Object(); @@ -661,7 +661,7 @@ public final class XmrConnectionService { if (isShutDownStarted) return; // log error message periodically - if ((lastErrorTimestamp == null || System.currentTimeMillis() - lastErrorTimestamp > MIN_ERROR_LOG_PERIOD_MS)) { + if ((lastErrorTimestamp == null || System.currentTimeMillis() - lastErrorTimestamp > LOG_POLL_ERROR_AFTER_MS)) { lastErrorTimestamp = System.currentTimeMillis(); log.warn("Could not update daemon info: " + e.getMessage()); if (DevEnv.isDevMode()) e.printStackTrace(); diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 08378aef6a..0e4726f6e7 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -132,6 +132,8 @@ public class XmrWalletService { private static final String THREAD_ID = XmrWalletService.class.getSimpleName(); private static final long SHUTDOWN_TIMEOUT_MS = 60000; private static final long NUM_BLOCKS_BEHIND_TOLERANCE = 5; + private static final long LOG_POLL_ERROR_AFTER_MS = 180000; // log poll error if unsuccessful after this time + private static Long lastPollSuccessTimestamp; private final User user; private final Preferences preferences; @@ -1803,9 +1805,14 @@ public class XmrWalletService { synchronized (WALLET_LOCK) { // avoid long fetch from blocking other operations synchronized (HavenoUtils.getDaemonLock()) { try { - cachedTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true)); + cachedTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true)); + lastPollSuccessTimestamp = System.currentTimeMillis(); } catch (Exception e) { // fetch from pool can fail - if (!isShutDownStarted) log.warn("Error polling main wallet's transactions from the pool: {}", e.getMessage()); + if (!isShutDownStarted) { + if (lastPollSuccessTimestamp == null || System.currentTimeMillis() - lastPollSuccessTimestamp > LOG_POLL_ERROR_AFTER_MS) { // only log if not recently successful + log.warn("Error polling main wallet's transactions from the pool: {}", e.getMessage()); + } + } } } }