From ad7d3d97de2e90aa6f1fee1d6fc32a63a092e075 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Fri, 3 Mar 2023 16:58:40 +0900 Subject: [PATCH 1/2] Wipe nodejs backend cache for any mining pool change --- backend/src/api/pools-parser.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/src/api/pools-parser.ts b/backend/src/api/pools-parser.ts index f17df385a..f94c147a2 100644 --- a/backend/src/api/pools-parser.ts +++ b/backend/src/api/pools-parser.ts @@ -39,6 +39,10 @@ class PoolsParser { * @param pools */ public async migratePoolsJson(): Promise { + // We also need to wipe the backend cache to make sure we don't serve blocks with + // the wrong mining pool (usually happen with unknown blocks) + diskCache.wipeCache(); + await this.$insertUnknownPool(); for (const pool of this.miningPools) { @@ -142,10 +146,6 @@ class PoolsParser { WHERE pool_id = ?`, [pool.id] ); - - // We also need to wipe the backend cache to make sure we don't serve blocks with - // the wrong mining pool (usually happen with unknown blocks) - diskCache.wipeCache(); } private async $deleteUnknownBlocks(): Promise { @@ -156,10 +156,6 @@ class PoolsParser { WHERE pool_id = ? AND height >= 130635`, [unknownPool[0].id] ); - - // We also need to wipe the backend cache to make sure we don't serve blocks with - // the wrong mining pool (usually happen with unknown blocks) - diskCache.wipeCache(); } } From d76d14253aece830caa9ac3ce7c8ef14012406c3 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Fri, 3 Mar 2023 17:29:46 +0900 Subject: [PATCH 2/2] Update mining pools before loading the disk cache since we may need to wipe that cache --- backend/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 812b49e15..29a6b1a72 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -113,6 +113,7 @@ class Server { this.setUpWebsocketHandling(); + await poolsUpdater.updatePoolsJson(); // Needs to be done before loading the disk cache because we sometimes wipe it await syncAssets.syncAssets$(); if (config.MEMPOOL.ENABLED) { diskCache.loadMempoolCache(); @@ -171,7 +172,6 @@ class Server { logger.debug(msg); } } - await poolsUpdater.updatePoolsJson(); await blocks.$updateBlocks(); await memPool.$updateMempool(); indexer.$run();