From a32f960c4af1b4a11d306d9b2865a19c38830c34 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 31 Oct 2022 11:07:28 -0600 Subject: [PATCH] db migration to clear obsolete audit data --- backend/src/api/database-migration.ts | 7 ++++++- backend/src/api/websocket-handler.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index 3bbd501fc..441ad2785 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -4,7 +4,7 @@ import logger from '../logger'; import { Common } from './common'; class DatabaseMigration { - private static currentVersion = 43; + private static currentVersion = 44; private queryTimeout = 120000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -360,6 +360,11 @@ class DatabaseMigration { if (databaseSchemaVersion < 43 && isBitcoin === true) { await this.$executeQuery(this.getCreateLNNodeRecordsTableQuery(), await this.$checkIfTableExists('nodes_records')); } + + if (databaseSchemaVersion < 44 && isBitcoin === true) { + await this.$executeQuery('TRUNCATE TABLE `blocks_audits`'); + await this.$executeQuery('UPDATE blocks_summaries SET template = NULL'); + } } /** diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 4bd7cfc8d..ed29646ef 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -416,7 +416,7 @@ class WebsocketHandler { let matchRate; const _memPool = memPool.getMempool(); - if (Common.indexingEnabled()) { + if (Common.indexingEnabled() && memPool.isInSync()) { const mempoolCopy = cloneMempool(_memPool); const projectedBlocks = mempoolBlocks.makeBlockTemplates(mempoolCopy, 2);