Add expected total fees audit

This commit is contained in:
Joost Jager
2023-06-05 13:20:46 +02:00
parent 153f0df3f6
commit 4022803a79
6 changed files with 28 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository';
import { RowDataPacket } from 'mysql2';
class DatabaseMigration {
private static currentVersion = 60;
private static currentVersion = 61;
private queryTimeout = 3600_000;
private statisticsAddedIndexed = false;
private uniqueLogs: string[] = [];
@@ -521,6 +521,11 @@ class DatabaseMigration {
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD sigop_txs JSON DEFAULT "[]"');
await this.updateToSchemaVersion(60);
}
if (databaseSchemaVersion < 61 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD expected_fees BIGINT UNSIGNED NOT NULL DEFAULT "0"');
await this.updateToSchemaVersion(61);
}
}
/**

View File

@@ -559,6 +559,8 @@ class WebsocketHandler {
}
if (Common.indexingEnabled() && memPool.isInSync()) {
logger.debug(`Auditing block ${block.height} (${block.id})`);
const { censored, added, fresh, sigop, score, similarity } = Audit.auditBlock(transactions, projectedBlocks, auditMempool);
const matchRate = Math.round(score * 100 * 100) / 100;
@@ -571,11 +573,14 @@ class WebsocketHandler {
};
}) : [];
const totalFees = stripped.reduce((total, transaction) => total + transaction.fee, 0);
logger.debug(`Projected block fees: ${totalFees} sats`);
BlocksSummariesRepository.$saveTemplate({
height: block.height,
template: {
id: block.id,
transactions: stripped
transactions: stripped,
}
});
@@ -588,6 +593,7 @@ class WebsocketHandler {
freshTxs: fresh,
sigopTxs: sigop,
matchRate: matchRate,
expectedFees: totalFees
});
if (block.extras) {