Fix more Goggles indexing bugs

This commit is contained in:
Mononaut 2024-01-24 12:18:42 +00:00
parent 8ca2b2b5c0
commit 09a727c00d
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -611,7 +611,7 @@ class Blocks {
if (unclassifiedBlocks[height]) { if (unclassifiedBlocks[height]) {
const blockHash = unclassifiedBlocks[height]; const blockHash = unclassifiedBlocks[height];
// fetch transactions // fetch transactions
txs = (await bitcoinApi.$getTxsForBlock(blockHash)).map(tx => transactionUtils.extendTransaction(tx)); txs = (await bitcoinApi.$getTxsForBlock(blockHash)).map(tx => transactionUtils.extendTransaction(tx)) || [];
// add CPFP // add CPFP
const cpfpSummary = Common.calculateCpfp(height, txs, true); const cpfpSummary = Common.calculateCpfp(height, txs, true);
// classify // classify
@ -622,7 +622,7 @@ class Blocks {
// classify template // classify template
const blockHash = unclassifiedTemplates[height]; const blockHash = unclassifiedTemplates[height];
const template = await BlocksSummariesRepository.$getTemplate(blockHash); const template = await BlocksSummariesRepository.$getTemplate(blockHash);
const alreadyClassified = template?.transactions.reduce((classified, tx) => (classified || tx.flags > 0), false); const alreadyClassified = template?.transactions?.reduce((classified, tx) => (classified || tx.flags > 0), false);
let classifiedTemplate = template?.transactions || []; let classifiedTemplate = template?.transactions || [];
if (!alreadyClassified) { if (!alreadyClassified) {
const templateTxs: (TransactionExtended | TransactionClassified)[] = []; const templateTxs: (TransactionExtended | TransactionClassified)[] = [];
@ -641,7 +641,7 @@ class Blocks {
} }
templateTxs.push(tx || templateTx); templateTxs.push(tx || templateTx);
} }
const cpfpSummary = Common.calculateCpfp(height, txs?.filter(tx => tx.effectiveFeePerVsize != null) as TransactionExtended[], true); const cpfpSummary = Common.calculateCpfp(height, templateTxs?.filter(tx => tx['effectiveFeePerVsize'] != null) as TransactionExtended[], true);
// classify // classify
const { transactions: classifiedTxs } = this.summarizeBlockTransactions(blockHash, cpfpSummary.transactions); const { transactions: classifiedTxs } = this.summarizeBlockTransactions(blockHash, cpfpSummary.transactions);
const classifiedTxMap: { [txid: string]: TransactionClassified } = {}; const classifiedTxMap: { [txid: string]: TransactionClassified } = {};
@ -662,8 +662,10 @@ class Blocks {
} }
// timing & logging // timing & logging
indexedThisRun++; if (unclassifiedBlocks[height] || unclassifiedTemplates[height]) {
indexedTotal++; indexedThisRun++;
indexedTotal++;
}
const elapsedSeconds = (Date.now() - timer) / 1000; const elapsedSeconds = (Date.now() - timer) / 1000;
if (elapsedSeconds > 5) { if (elapsedSeconds > 5) {
const perSecond = indexedThisRun / elapsedSeconds; const perSecond = indexedThisRun / elapsedSeconds;