diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index ba4dfa8bd..b95756ae5 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -566,7 +566,7 @@ class Blocks { */ public async $classifyBlocks(): Promise { // classification requires an esplora backend - if (config.MEMPOOL.BACKEND !== 'esplora') { + if (!Common.blocksSummariesIndexingEnabled() || config.MEMPOOL.BACKEND !== 'esplora') { return; } @@ -577,7 +577,7 @@ class Blocks { const unclassifiedTemplatesList = await BlocksSummariesRepository.$getTemplatesWithVersion(0); // nothing to do - if (!unclassifiedBlocksList.length && !unclassifiedTemplatesList.length) { + if (!unclassifiedBlocksList?.length && !unclassifiedTemplatesList?.length) { return; } @@ -586,8 +586,8 @@ class Blocks { let indexedTotal = 0; const minHeight = Math.min( - unclassifiedBlocksList[unclassifiedBlocksList.length - 1].height ?? Infinity, - unclassifiedTemplatesList[unclassifiedTemplatesList.length - 1].height ?? Infinity, + unclassifiedBlocksList[unclassifiedBlocksList.length - 1]?.height ?? Infinity, + unclassifiedTemplatesList[unclassifiedTemplatesList.length - 1]?.height ?? Infinity, ); const numToIndex = Math.max( unclassifiedBlocksList.length, diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index e83ad4536..162616af6 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -559,7 +559,7 @@ class DatabaseMigration { await this.updateToSchemaVersion(66); } - if (databaseSchemaVersion < 67) { + if (databaseSchemaVersion < 67 && isBitcoin === true) { await this.$executeQuery('ALTER TABLE `blocks_summaries` ADD version INT NOT NULL DEFAULT 0'); await this.$executeQuery('ALTER TABLE `blocks_summaries` ADD INDEX `version` (`version`)'); await this.$executeQuery('ALTER TABLE `blocks_templates` ADD version INT NOT NULL DEFAULT 0');