remove extraneous errors on daemon disconnect, one warning per 5 minutes

This commit is contained in:
woodser 2023-02-26 15:24:43 -05:00
parent 05b259bd55
commit 34b79e779b
3 changed files with 21 additions and 10 deletions

View File

@ -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 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_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 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 // default Monero nodes
private static final Map<BaseCurrencyNetwork, List<MoneroRpcConnection>> DEFAULT_CONNECTIONS; private static final Map<BaseCurrencyNetwork, List<MoneroRpcConnection>> DEFAULT_CONNECTIONS;
@ -441,9 +443,16 @@ public final class CoreMoneroConnectionsService {
peers.set(new ArrayList<MoneroPeer>()); // TODO: peers unknown due to restricted RPC call peers.set(new ArrayList<MoneroPeer>()); // TODO: peers unknown due to restricted RPC call
} }
numPeers.set(peers.get().size()); numPeers.set(peers.get().size());
if (lastErrorTimestamp != null) {
log.info("Successfully fetched daemon info after previous error");
lastErrorTimestamp = null;
}
} catch (Exception e) { } catch (Exception e) {
log.warn("Could not update daemon info: " + e.getMessage()); if (lastErrorTimestamp == null || System.currentTimeMillis() - lastErrorTimestamp > MIN_ERROR_LOG_PERIOD_MS) {
if (DevEnv.isDevMode()) e.printStackTrace(); lastErrorTimestamp = System.currentTimeMillis();
log.warn("Could not update daemon info: " + e.getMessage());
if (DevEnv.isDevMode()) e.printStackTrace();
}
if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection()); if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection());
} }
} }

View File

@ -677,7 +677,7 @@ public class XmrWalletService {
if (wallet == null) maybeInitMainWallet(); if (wallet == null) maybeInitMainWallet();
else { else {
wallet.setDaemonConnection(connection); wallet.setDaemonConnection(connection);
if (connection != null) new Thread(() -> trySyncMainWallet()).start(); if (connection != null && !Boolean.FALSE.equals(connection.isConnected())) new Thread(() -> trySyncMainWallet()).start();
} }
} }

View File

@ -1648,13 +1648,15 @@ public abstract class Trade implements Tradable, Model {
wallet.setDaemonConnection(connection); wallet.setDaemonConnection(connection);
// sync and reprocess messages on new thread // sync and reprocess messages on new thread
HavenoUtils.submitTask(() -> { if (connection != null && !Boolean.FALSE.equals(connection.isConnected())) {
updateSyncing(); HavenoUtils.submitTask(() -> {
updateSyncing();
// reprocess pending payout messages // reprocess pending payout messages
this.getProtocol().maybeReprocessPaymentReceivedMessage(false); this.getProtocol().maybeReprocessPaymentReceivedMessage(false);
HavenoUtils.arbitrationManager.maybeReprocessDisputeClosedMessage(this, false); HavenoUtils.arbitrationManager.maybeReprocessDisputeClosedMessage(this, false);
}); });
}
} }
private void updateSyncing() { private void updateSyncing() {