diff --git a/backend/src/api/mining/mining.ts b/backend/src/api/mining/mining.ts index 20da92de3..39a4423f2 100644 --- a/backend/src/api/mining/mining.ts +++ b/backend/src/api/mining/mining.ts @@ -472,11 +472,11 @@ class Mining { } this.blocksPriceIndexingRunning = true; + let totalInserted = 0; try { const prices: any[] = await PricesRepository.$getPricesTimesAndId(); const blocksWithoutPrices: any[] = await BlocksRepository.$getBlocksWithoutPrice(); - let totalInserted = 0; const blocksPrices: BlockPrice[] = []; for (const block of blocksWithoutPrices) { @@ -521,7 +521,13 @@ class Mining { } } catch (e) { this.blocksPriceIndexingRunning = false; - throw e; + logger.err(`Cannot index block prices. ${e}`); + } + + if (totalInserted > 0) { + logger.info(`Indexing blocks prices completed. Indexed ${totalInserted}`, logger.tags.mining); + } else { + logger.debug(`Indexing blocks prices completed. Indexed 0.`, logger.tags.mining); } this.blocksPriceIndexingRunning = false; diff --git a/backend/src/repositories/BlocksRepository.ts b/backend/src/repositories/BlocksRepository.ts index 5848fe331..90cebf7e9 100644 --- a/backend/src/repositories/BlocksRepository.ts +++ b/backend/src/repositories/BlocksRepository.ts @@ -577,19 +577,6 @@ class BlocksRepository { } } - /** - * Return blocks height - */ - public async $getBlocksHeightsAndTimestamp(): Promise { - try { - const [rows]: any[] = await DB.query(`SELECT height, blockTimestamp as timestamp FROM blocks`); - return rows; - } catch (e) { - logger.err('Cannot get blocks height and timestamp from the db. Reason: ' + (e instanceof Error ? e.message : e)); - throw e; - } - } - /** * Get general block stats */ @@ -877,7 +864,7 @@ class BlocksRepository { /** * Get all blocks which have not be linked to a price yet */ - public async $getBlocksWithoutPrice(): Promise { + public async $getBlocksWithoutPrice(): Promise { try { const [rows]: any[] = await DB.query(` SELECT UNIX_TIMESTAMP(blocks.blockTimestamp) as timestamp, blocks.height @@ -889,7 +876,7 @@ class BlocksRepository { return rows; } catch (e) { logger.err('Cannot get blocks height and timestamp from the db. Reason: ' + (e instanceof Error ? e.message : e)); - throw e; + return []; } } @@ -909,7 +896,6 @@ class BlocksRepository { logger.debug(`Cannot save blocks prices for blocks [${blockPrices[0].height} to ${blockPrices[blockPrices.length - 1].height}] because it has already been indexed, ignoring`); } else { logger.err(`Cannot save blocks prices for blocks [${blockPrices[0].height} to ${blockPrices[blockPrices.length - 1].height}] into db. Reason: ` + (e instanceof Error ? e.message : e)); - throw e; } } }