From 9900f4da8040ac726d582df8ae693aa8d83dd158 Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 20 Jan 2021 17:16:43 +0700 Subject: [PATCH] Set backend to out of sync after connection retry interval has exceeded. --- backend/src/api/mempool.ts | 7 ++++++- backend/src/index.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/api/mempool.ts b/backend/src/api/mempool.ts index c00d5c10c..7ec3a93a2 100644 --- a/backend/src/api/mempool.ts +++ b/backend/src/api/mempool.ts @@ -29,10 +29,15 @@ class Mempool { setInterval(this.updateTxPerSecond.bind(this), 1000); } - public isInSync() { + public isInSync(): boolean { return this.inSync; } + public setOutOfSync(): void { + this.inSync = false; + loadingIndicators.setProgress('mempool', 99); + } + public getLatestTransactions() { return this.latestTransactions; } diff --git a/backend/src/index.ts b/backend/src/index.ts index 98bbe4cd1..ac7acca50 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -21,6 +21,7 @@ import donations from './api/donations'; import logger from './logger'; import backendInfo from './api/backend-info'; import loadingIndicators from './api/loading-indicators'; +import mempool from './api/mempool'; class Server { private wss: WebSocket.Server | undefined; @@ -120,6 +121,7 @@ class Server { const loggerMsg = `runMainLoop error: ${(e.message || e)}. Retrying in ${this.currentBackendRetryInterval} sec.`; if (this.currentBackendRetryInterval > 5) { logger.warn(loggerMsg); + mempool.setOutOfSync(); } else { logger.debug(loggerMsg); }