Add expected weight to audit table

This commit is contained in:
Mononaut
2023-06-09 13:46:14 -04:00
parent a74a9fe73a
commit 9433e7a1a5
9 changed files with 98 additions and 22 deletions

View File

@@ -534,7 +534,8 @@ class DatabaseMigration {
}
if (databaseSchemaVersion < 62 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD expected_fees BIGINT UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD expected_fees BIGINT UNSIGNED DEFAULT NULL');
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD expected_weight BIGINT UNSIGNED DEFAULT NULL');
await this.updateToSchemaVersion(62);
}

View File

@@ -559,8 +559,6 @@ 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;
@@ -573,8 +571,12 @@ class WebsocketHandler {
};
}) : [];
const totalFees = stripped.reduce((total, transaction) => total + transaction.fee, 0);
logger.debug(`Projected block fees: ${totalFees} sats`);
let totalFees = 0;
let totalWeight = 0;
for (const tx of stripped) {
totalFees += tx.fee;
totalWeight += (tx.vsize * 4);
}
BlocksSummariesRepository.$saveTemplate({
height: block.height,
@@ -593,7 +595,8 @@ class WebsocketHandler {
freshTxs: fresh,
sigopTxs: sigop,
matchRate: matchRate,
expectedFees: totalFees
expectedFees: totalFees,
expectedWeight: totalWeight,
});
if (block.extras) {