From 761edbce9ae5c35baf9ff8071a4f5bce1f0145a2 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 19 Feb 2023 19:08:29 +0900 Subject: [PATCH] Fix database usage when database is disabled --- backend/src/api/blocks.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 3f2a7b49e..d110186f5 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -600,9 +600,11 @@ class Blocks { * Index a block if it's missing from the database. Returns the block after indexing */ public async $indexBlock(height: number): Promise { - const dbBlock = await blocksRepository.$getBlockByHeight(height); - if (dbBlock != null) { - return prepareBlock(dbBlock); + if (Common.indexingEnabled()) { + const dbBlock = await blocksRepository.$getBlockByHeight(height); + if (dbBlock !== null) { + return prepareBlock(dbBlock); + } } const blockHash = await bitcoinApi.$getBlockHash(height);