Fix database usage when database is disabled

This commit is contained in:
nymkappa 2023-02-19 19:08:29 +09:00
parent f6800b848a
commit 761edbce9a
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -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<BlockExtended> {
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);