Show expected fees in blocks list

This commit is contained in:
Joost Jager 2023-06-06 08:52:29 +02:00
parent 3c0bb11208
commit 74b2014dff
No known key found for this signature in database
GPG Key ID: B9A26449A5528325
7 changed files with 15 additions and 2 deletions

View File

@ -282,10 +282,12 @@ class Blocks {
} }
extras.matchRate = null; extras.matchRate = null;
extras.expectedFees = null;
if (config.MEMPOOL.AUDIT) { if (config.MEMPOOL.AUDIT) {
const auditScore = await BlocksAuditsRepository.$getBlockAuditScore(block.id); const auditScore = await BlocksAuditsRepository.$getBlockAuditScore(block.id);
if (auditScore != null) { if (auditScore != null) {
extras.matchRate = auditScore.matchRate; extras.matchRate = auditScore.matchRate;
extras.expectedFees = auditScore.expectedFees;
} }
} }
} }

View File

@ -598,6 +598,7 @@ class WebsocketHandler {
if (block.extras) { if (block.extras) {
block.extras.matchRate = matchRate; block.extras.matchRate = matchRate;
block.extras.expectedFees = totalFees;
block.extras.similarity = similarity; block.extras.similarity = similarity;
} }
} }

View File

@ -41,6 +41,7 @@ export interface BlockAudit {
export interface AuditScore { export interface AuditScore {
hash: string, hash: string,
matchRate?: number, matchRate?: number,
expectedFees?: number
} }
export interface MempoolBlock { export interface MempoolBlock {
@ -183,6 +184,7 @@ export interface BlockExtension {
feeRange: number[]; // fee rate percentiles feeRange: number[]; // fee rate percentiles
reward: number; reward: number;
matchRate: number | null; matchRate: number | null;
expectedFees: number | null;
similarity?: number; similarity?: number;
pool: { pool: {
id: number; // Note - This is the `unique_id`, not to mix with the auto increment `id` id: number; // Note - This is the `unique_id`, not to mix with the auto increment `id`

View File

@ -81,7 +81,7 @@ class BlocksAuditRepositories {
public async $getBlockAuditScore(hash: string): Promise<AuditScore> { public async $getBlockAuditScore(hash: string): Promise<AuditScore> {
try { try {
const [rows]: any[] = await DB.query( const [rows]: any[] = await DB.query(
`SELECT hash, match_rate as matchRate `SELECT hash, match_rate as matchRate, expected_fees as expectedFees
FROM blocks_audits FROM blocks_audits
WHERE blocks_audits.hash = "${hash}" WHERE blocks_audits.hash = "${hash}"
`); `);
@ -95,7 +95,7 @@ class BlocksAuditRepositories {
public async $getBlockAuditScores(maxHeight: number, minHeight: number): Promise<AuditScore[]> { public async $getBlockAuditScores(maxHeight: number, minHeight: number): Promise<AuditScore[]> {
try { try {
const [rows]: any[] = await DB.query( const [rows]: any[] = await DB.query(
`SELECT hash, match_rate as matchRate `SELECT hash, match_rate as matchRate, expected_fees as expectedFees
FROM blocks_audits FROM blocks_audits
WHERE blocks_audits.height BETWEEN ? AND ? WHERE blocks_audits.height BETWEEN ? AND ?
`, [minHeight, maxHeight]); `, [minHeight, maxHeight]);

View File

@ -1032,10 +1032,12 @@ class BlocksRepository {
// Match rate is not part of the blocks table, but it is part of APIs so we must include it // Match rate is not part of the blocks table, but it is part of APIs so we must include it
extras.matchRate = null; extras.matchRate = null;
extras.expectedFees = null;
if (config.MEMPOOL.AUDIT) { if (config.MEMPOOL.AUDIT) {
const auditScore = await BlocksAuditsRepository.$getBlockAuditScore(dbBlk.id); const auditScore = await BlocksAuditsRepository.$getBlockAuditScore(dbBlk.id);
if (auditScore != null) { if (auditScore != null) {
extras.matchRate = auditScore.matchRate; extras.matchRate = auditScore.matchRate;
extras.expectedFees = auditScore.expectedFees;
} }
} }

View File

@ -16,6 +16,8 @@
<th class="mined" i18n="latest-blocks.mined" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'">Mined</th> <th class="mined" i18n="latest-blocks.mined" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'">Mined</th>
<th *ngIf="auditAvailable" class="health text-right" i18n="latest-blocks.health" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}" <th *ngIf="auditAvailable" class="health text-right" i18n="latest-blocks.health" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"
i18n-ngbTooltip="latest-blocks.health" ngbTooltip="Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Health</th> i18n-ngbTooltip="latest-blocks.health" ngbTooltip="Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Health</th>
<th *ngIf="auditAvailable" class="text-right" i18n="latest-blocks.expected-fees" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"
i18n-ngbTooltip="latest-blocks.expected-fees" ngbTooltip="Expected fees" placement="bottom">Expected fees</th>
<th *ngIf="indexingAvailable" class="reward text-right" i18n="latest-blocks.reward" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}" <th *ngIf="indexingAvailable" class="reward text-right" i18n="latest-blocks.reward" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"
i18n-ngbTooltip="latest-blocks.reward" ngbTooltip="Reward" placement="bottom" #reward [disableTooltip]="!isEllipsisActive(reward)">Reward</th> i18n-ngbTooltip="latest-blocks.reward" ngbTooltip="Reward" placement="bottom" #reward [disableTooltip]="!isEllipsisActive(reward)">Reward</th>
<th *ngIf="indexingAvailable && !widget" class="fees text-right" i18n="latest-blocks.fees" [class]="indexingAvailable ? '' : 'legacy'">Fees</th> <th *ngIf="indexingAvailable && !widget" class="fees text-right" i18n="latest-blocks.fees" [class]="indexingAvailable ? '' : 'legacy'">Fees</th>
@ -64,6 +66,9 @@
<span class="skeleton-loader" style="max-width: 60px"></span> <span class="skeleton-loader" style="max-width: 60px"></span>
</ng-template> </ng-template>
</td> </td>
<td *ngIf="auditAvailable" class="text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}">
<app-amount [satoshis]="block.extras.expectedFees" [noFiat]="true" digitsInfo="1.2-2"></app-amount>
</td>
<td *ngIf="indexingAvailable" class="reward text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> <td *ngIf="indexingAvailable" class="reward text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}">
<app-amount [satoshis]="block.extras.reward" [noFiat]="true" digitsInfo="1.2-2"></app-amount> <app-amount [satoshis]="block.extras.reward" [noFiat]="true" digitsInfo="1.2-2"></app-amount>
</td> </td>

View File

@ -133,6 +133,7 @@ export interface BlockExtension {
reward?: number; reward?: number;
coinbaseRaw?: string; coinbaseRaw?: string;
matchRate?: number; matchRate?: number;
expectedFees?: number;
similarity?: number; similarity?: number;
pool?: { pool?: {
id: number; id: number;