mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 05:03:35 +01:00
limit logging of poll errors to once every 4 minutes
This commit is contained in:
parent
8b7e95f614
commit
caaf9f7b5b
@ -70,8 +70,6 @@ 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 LOG_POLL_ERROR_AFTER_MS = 300000; // minimum period between logging errors fetching daemon info
|
||||
private static Long lastErrorTimestamp;
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final Object pollLock = new Object();
|
||||
@ -100,6 +98,7 @@ public final class XmrConnectionService {
|
||||
private Boolean isConnected = false;
|
||||
@Getter
|
||||
private MoneroDaemonInfo lastInfo;
|
||||
private Long lastLogPollErrorTimestamp;
|
||||
private Long syncStartHeight = null;
|
||||
private TaskLooper daemonPollLooper;
|
||||
@Getter
|
||||
@ -680,8 +679,14 @@ public final class XmrConnectionService {
|
||||
return;
|
||||
}
|
||||
|
||||
// log error message periodically
|
||||
if ((lastLogPollErrorTimestamp == null || System.currentTimeMillis() - lastLogPollErrorTimestamp > HavenoUtils.LOG_POLL_ERROR_PERIOD_MS)) {
|
||||
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
|
||||
if (DevEnv.isDevMode()) e.printStackTrace();
|
||||
lastLogPollErrorTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// switch to best connection
|
||||
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
|
||||
switchToBestConnection();
|
||||
lastInfo = daemon.getInfo(); // caught internally if still fails
|
||||
}
|
||||
@ -722,9 +727,9 @@ public final class XmrConnectionService {
|
||||
});
|
||||
|
||||
// handle error recovery
|
||||
if (lastErrorTimestamp != null) {
|
||||
if (lastLogPollErrorTimestamp != null) {
|
||||
log.info("Successfully fetched daemon info after previous error");
|
||||
lastErrorTimestamp = null;
|
||||
lastLogPollErrorTimestamp = null;
|
||||
}
|
||||
|
||||
// clear error message
|
||||
@ -737,13 +742,6 @@ public final class XmrConnectionService {
|
||||
// skip if shut down
|
||||
if (isShutDownStarted) return;
|
||||
|
||||
// log error message periodically
|
||||
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();
|
||||
}
|
||||
|
||||
// set error message
|
||||
getConnectionServiceErrorMsg().set(e.getMessage());
|
||||
} finally {
|
||||
|
@ -78,6 +78,9 @@ public class HavenoUtils {
|
||||
public static final double TAKER_FEE_PCT = 0.0075; // 0.75%
|
||||
public static final double PENALTY_FEE_PCT = 0.02; // 2%
|
||||
|
||||
// other configuration
|
||||
public static final long LOG_POLL_ERROR_PERIOD_MS = 1000 * 60 * 4; // log poll errors up to once every 4 minutes
|
||||
|
||||
// synchronize requests to the daemon
|
||||
private static boolean SYNC_DAEMON_REQUESTS = true; // sync long requests to daemon (e.g. refresh, update pool)
|
||||
private static boolean SYNC_WALLET_REQUESTS = false; // additionally sync wallet functions to daemon (e.g. create txs)
|
||||
@ -99,7 +102,7 @@ public class HavenoUtils {
|
||||
public static final DecimalFormat XMR_FORMATTER = new DecimalFormat("##############0.000000000000", DECIMAL_FORMAT_SYMBOLS);
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
|
||||
// TODO: better way to share references?
|
||||
// shared references TODO: better way to share references?
|
||||
public static HavenoSetup havenoSetup;
|
||||
public static ArbitrationManager arbitrationManager;
|
||||
public static XmrWalletService xmrWalletService;
|
||||
|
@ -32,6 +32,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
|
||||
/**
|
||||
* Poll for changes to the spent status of key images.
|
||||
*
|
||||
@ -47,6 +49,7 @@ public class XmrKeyImagePoller {
|
||||
private TaskLooper looper;
|
||||
private Map<String, MoneroKeyImageSpentStatus> lastStatuses = new HashMap<String, MoneroKeyImageSpentStatus>();
|
||||
private boolean isPolling = false;
|
||||
private Long lastLogPollErrorTimestamp;
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
@ -265,7 +268,12 @@ public class XmrKeyImagePoller {
|
||||
spentStatuses = daemon.getKeyImageSpentStatuses(keyImages); // TODO monero-java: if order of getKeyImageSpentStatuses is guaranteed, then it should take list parameter
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Error polling spent status of key images: " + e.getMessage());
|
||||
|
||||
// limit error logging
|
||||
if (lastLogPollErrorTimestamp == null || System.currentTimeMillis() - lastLogPollErrorTimestamp > HavenoUtils.LOG_POLL_ERROR_PERIOD_MS) {
|
||||
log.warn("Error polling spent status of key images: " + e.getMessage());
|
||||
lastLogPollErrorTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -134,8 +134,6 @@ 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;
|
||||
@ -172,6 +170,7 @@ public class XmrWalletService {
|
||||
private TaskLooper pollLooper;
|
||||
private boolean pollInProgress;
|
||||
private Long pollPeriodMs;
|
||||
private Long lastLogPollErrorTimestamp;
|
||||
private final Object pollLock = new Object();
|
||||
private Long cachedHeight;
|
||||
private BigInteger cachedBalance;
|
||||
@ -1846,11 +1845,12 @@ public class XmrWalletService {
|
||||
synchronized (HavenoUtils.getDaemonLock()) {
|
||||
try {
|
||||
cachedTxs = wallet.getTxs(new MoneroTxQuery().setIncludeOutputs(true));
|
||||
lastPollSuccessTimestamp = System.currentTimeMillis();
|
||||
lastLogPollErrorTimestamp = null;
|
||||
} catch (Exception e) { // fetch from pool can fail
|
||||
if (!isShutDownStarted) {
|
||||
if (lastPollSuccessTimestamp == null || System.currentTimeMillis() - lastPollSuccessTimestamp > LOG_POLL_ERROR_AFTER_MS) { // only log if not recently successful
|
||||
if (lastLogPollErrorTimestamp == null || System.currentTimeMillis() - lastLogPollErrorTimestamp > HavenoUtils.LOG_POLL_ERROR_PERIOD_MS) { // limit error logging
|
||||
log.warn("Error polling main wallet's transactions from the pool: {}", e.getMessage());
|
||||
lastLogPollErrorTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user