From 32733a30230ef8bea9c8d6afc97883f157d690a0 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 26 Feb 2023 11:30:12 +0900 Subject: [PATCH 1/3] When we re-index blocks due to mining pools change, wipe the nodejs backend cache --- backend/src/api/disk-cache.ts | 1 + backend/src/api/pools-parser.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/backend/src/api/disk-cache.ts b/backend/src/api/disk-cache.ts index a75fd43cc..e466982ad 100644 --- a/backend/src/api/disk-cache.ts +++ b/backend/src/api/disk-cache.ts @@ -62,6 +62,7 @@ class DiskCache { } wipeCache() { + logger.notice(`Wipping nodejs backend cache/cache*.json files`); fs.unlinkSync(DiskCache.FILE_NAME); for (let i = 1; i < DiskCache.CHUNK_FILES; i++) { fs.unlinkSync(DiskCache.FILE_NAMES.replace('{number}', i.toString())); diff --git a/backend/src/api/pools-parser.ts b/backend/src/api/pools-parser.ts index 4e67ce98b..d1705b829 100644 --- a/backend/src/api/pools-parser.ts +++ b/backend/src/api/pools-parser.ts @@ -3,6 +3,7 @@ import logger from '../logger'; import config from '../config'; import PoolsRepository from '../repositories/PoolsRepository'; import { PoolTag } from '../mempool.interfaces'; +import diskCache from './disk-cache'; class PoolsParser { miningPools: any[] = []; @@ -139,6 +140,10 @@ 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 { @@ -149,6 +154,10 @@ 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 9a4a5ad94e0f1eed983de118a1f9ced4719dc5f5 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 26 Feb 2023 11:37:57 +0900 Subject: [PATCH 2/3] Silence ENOENT exception when we wipe the nodejs backend cache --- backend/src/api/disk-cache.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/src/api/disk-cache.ts b/backend/src/api/disk-cache.ts index e466982ad..c6af20e29 100644 --- a/backend/src/api/disk-cache.ts +++ b/backend/src/api/disk-cache.ts @@ -63,9 +63,23 @@ class DiskCache { wipeCache() { logger.notice(`Wipping nodejs backend cache/cache*.json files`); - fs.unlinkSync(DiskCache.FILE_NAME); + try { + fs.unlinkSync(DiskCache.FILE_NAME); + } catch (e: any) { + if (e?.code !== 'ENOENT') { + logger.err(`Cannot wipe cache file ${DiskCache.FILE_NAME}. Exception ${JSON.stringify(e)}`); + } + } + for (let i = 1; i < DiskCache.CHUNK_FILES; i++) { - fs.unlinkSync(DiskCache.FILE_NAMES.replace('{number}', i.toString())); + const filename = DiskCache.FILE_NAMES.replace('{number}', i.toString()); + try { + fs.unlinkSync(filename); + } catch (e: any) { + if (e?.code !== 'ENOENT') { + logger.err(`Cannot wipe cache file ${filename}. Exception ${JSON.stringify(e)}`); + } + } } } From 0846f346eeaeff2d6bcaf355bb745b9dfd8522c4 Mon Sep 17 00:00:00 2001 From: softsimon Date: Fri, 3 Mar 2023 10:58:02 +0900 Subject: [PATCH 3/3] About page video improvements --- frontend/.gitignore | 1 + frontend/src/app/components/about/about.component.scss | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/.gitignore b/frontend/.gitignore index 789881ddd..9c4b5d5e8 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -54,6 +54,7 @@ src/resources/assets-testnet.json src/resources/assets-testnet.minimal.json src/resources/pools.json src/resources/mining-pools/* +src/resources/*.mp4 # environment config mempool-frontend-config.json diff --git a/frontend/src/app/components/about/about.component.scss b/frontend/src/app/components/about/about.component.scss index 35df3fc46..2efd2f73b 100644 --- a/frontend/src/app/components/about/about.component.scss +++ b/frontend/src/app/components/about/about.component.scss @@ -36,6 +36,7 @@ video { width: 640px; + height: 360px; max-width: 90%; margin-top: 0; }