Always fetch at least the coinbase transaction of blocks, and throw error if failed.

This commit is contained in:
softsimon 2021-01-24 23:56:51 +07:00
parent cca95bbd66
commit c9e175a0cc
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -70,13 +70,16 @@ class Blocks {
if (mempool[txIds[i]]) {
transactions.push(mempool[txIds[i]]);
transactionsFound++;
} else if (config.MEMPOOL.BACKEND === 'esplora' || memPool.isInSync()) {
} else if (config.MEMPOOL.BACKEND === 'esplora' || memPool.isInSync() || i === 0) {
logger.debug(`Fetching block tx ${i} of ${txIds.length}`);
try {
const tx = await transactionUtils.$getTransactionExtended(txIds[i]);
transactions.push(tx);
} catch (e) {
logger.debug('Error fetching block tx: ' + e.message || e);
if (i === 0) {
throw new Error('Failed to fetch Coinbase transaction: ' + txIds[i]);
}
}
}
}