From be4bd691eec804092b263ec51cb7377dce30b12e Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Thu, 2 Mar 2023 10:08:40 +0900 Subject: [PATCH] Remove useless code --- backend/src/api/blocks.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 12eb3b693..aa33f1ff7 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -748,30 +748,15 @@ class Blocks { return returnBlocks; } - // Check if block height exist in local cache to skip the hash lookup - const blockByHeight = this.getBlocks().find((b) => b.height === currentHeight); - let startFromHash: string | null = null; - if (blockByHeight) { - startFromHash = blockByHeight.id; - } else if (!Common.indexingEnabled()) { - startFromHash = await bitcoinApi.$getBlockHash(currentHeight); - } - - let nextHash = startFromHash; for (let i = 0; i < limit && currentHeight >= 0; i++) { let block = this.getBlocks().find((b) => b.height === currentHeight); if (block) { // Using the memory cache (find by height) returnBlocks.push(block); - } else if (Common.indexingEnabled()) { + } else { // Using indexing (find by height, index on the fly, save in database) block = await this.$indexBlock(currentHeight); returnBlocks.push(block); - } else if (nextHash !== null) { - // Without indexing, query block on the fly using bitoin backend, follow previous hash links - block = await this.$indexBlock(currentHeight); - nextHash = block.previousblockhash; - returnBlocks.push(block); } currentHeight--; }