Add expected weight to audit table

This commit is contained in:
Mononaut committed 2023-06-10 12:32:53 -04:00
1 parent aedaf53137
commit 3013386ca5
9 files changed
+98 -22

No files matched your search

+2 -1
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);
}
+8 -5
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) {