Merge pull request #3080 from mempool/nymkappa/bugfix/invalid-db-use

Fix database usage when database is disabled
This commit is contained in:
softsimon 2023-02-19 21:08:40 +07:00 committed by GitHub
commit ee6bdeec66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,9 +600,11 @@ class Blocks {
* Index a block if it's missing from the database. Returns the block after indexing * Index a block if it's missing from the database. Returns the block after indexing
*/ */
public async $indexBlock(height: number): Promise<BlockExtended> { public async $indexBlock(height: number): Promise<BlockExtended> {
const dbBlock = await blocksRepository.$getBlockByHeight(height); if (Common.indexingEnabled()) {
if (dbBlock != null) { const dbBlock = await blocksRepository.$getBlockByHeight(height);
return prepareBlock(dbBlock); if (dbBlock !== null) {
return prepareBlock(dbBlock);
}
} }
const blockHash = await bitcoinApi.$getBlockHash(height); const blockHash = await bitcoinApi.$getBlockHash(height);