mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 17:47:01 +01:00
Only log warning if main update loop has failed more than once.
This commit is contained in:
parent
c6d0571be8
commit
b4a17693af
1 changed files with 10 additions and 5 deletions
|
@ -83,7 +83,7 @@ class Server {
|
|||
|
||||
this.setUpHttpApiRoutes();
|
||||
this.setUpWebsocketHandling();
|
||||
this.runMempoolIntervalFunctions();
|
||||
this.runMainUpdateLoop();
|
||||
|
||||
fiatConversion.startService();
|
||||
diskCache.loadMempoolCache();
|
||||
|
@ -107,16 +107,21 @@ class Server {
|
|||
});
|
||||
}
|
||||
|
||||
async runMempoolIntervalFunctions() {
|
||||
async runMainUpdateLoop() {
|
||||
try {
|
||||
await memPool.$updateMemPoolInfo();
|
||||
await blocks.$updateBlocks();
|
||||
await memPool.$updateMempool();
|
||||
setTimeout(this.runMempoolIntervalFunctions.bind(this), config.ELECTRS.POLL_RATE_MS);
|
||||
setTimeout(this.runMainUpdateLoop.bind(this), config.ELECTRS.POLL_RATE_MS);
|
||||
this.retryOnElectrsErrorAfterSeconds = 5;
|
||||
} catch (e) {
|
||||
logger.warn(`runMempoolIntervalFunctions error: ${(e.message || e)}. Retrying in ${this.retryOnElectrsErrorAfterSeconds} sec.`);
|
||||
setTimeout(this.runMempoolIntervalFunctions.bind(this), 1000 * this.retryOnElectrsErrorAfterSeconds);
|
||||
const loggerMsg = `runMainLoop error: ${(e.message || e)}. Retrying in ${this.retryOnElectrsErrorAfterSeconds} sec.`;
|
||||
if (this.retryOnElectrsErrorAfterSeconds > 5) {
|
||||
logger.warn(loggerMsg);
|
||||
} else {
|
||||
logger.debug(loggerMsg);
|
||||
}
|
||||
setTimeout(this.runMainUpdateLoop.bind(this), 1000 * this.retryOnElectrsErrorAfterSeconds);
|
||||
this.retryOnElectrsErrorAfterSeconds *= 2;
|
||||
this.retryOnElectrsErrorAfterSeconds = Math.min(this.retryOnElectrsErrorAfterSeconds, 60);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue