Set backend to out of sync after connection retry interval has exceeded.

This commit is contained in:
softsimon 2021-01-20 17:16:43 +07:00
parent a158794e2c
commit 9900f4da80
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 8 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);
}