Fix random console errors on block loading

This commit is contained in:
natsoni 2024-04-01 18:00:10 +09:00
parent 56b9715fc5
commit 3f80dbc5ce
No known key found for this signature in database
GPG Key ID: C65917583181743B
3 changed files with 12 additions and 12 deletions

View File

@ -39,7 +39,7 @@
<div class="col-sm"> <div class="col-sm">
<table class="table table-borderless table-striped"> <table class="table table-borderless table-striped">
<tbody> <tbody>
<ng-container *ngIf="!isLoadingBlock; else skeletonRows"> <ng-container *ngIf="block && !isLoadingBlock; else skeletonRows">
<tr> <tr>
<td class="td-width" i18n="block.hash">Hash</td> <td class="td-width" i18n="block.hash">Hash</td>
<td>&lrm;<a [routerLink]="['/block/' | relativeUrl, block.id]" title="{{ block.id }}">{{ block.id | shortenString : 13 }}</a> <app-clipboard [text]="block.id"></app-clipboard></td> <td>&lrm;<a [routerLink]="['/block/' | relativeUrl, block.id]" title="{{ block.id }}">{{ block.id | shortenString : 13 }}</a> <app-clipboard [text]="block.id"></app-clipboard></td>
@ -126,16 +126,16 @@
</div> </div>
<ng-template #restOfTable> <ng-template #restOfTable>
<ng-container *ngIf="!isLoadingBlock; else loadingRest"> <ng-container *ngIf="block && !isLoadingBlock; else loadingRest">
<tr *ngIf="network !== 'liquid' && network !== 'liquidtestnet'"> <tr *ngIf="network !== 'liquid' && network !== 'liquidtestnet'">
<td i18n="mempool-block.fee-span">Fee span</td> <td i18n="mempool-block.fee-span">Fee span</td>
<td><app-fee-rate [fee]="block?.extras?.minFee" [showUnit]="false" rounding="1.0-0"></app-fee-rate> - <app-fee-rate [fee]="block?.extras?.maxFee" rounding="1.0-0"></app-fee-rate></td> <td><app-fee-rate [fee]="block.extras?.minFee" [showUnit]="false" rounding="1.0-0"></app-fee-rate> - <app-fee-rate [fee]="block.extras?.maxFee" rounding="1.0-0"></app-fee-rate></td>
</tr> </tr>
<tr *ngIf="block?.extras?.medianFee != undefined"> <tr *ngIf="block.extras?.medianFee != undefined">
<td class="td-width" i18n="block.median-fee">Median fee</td> <td class="td-width" i18n="block.median-fee">Median fee</td>
<td>~<app-fee-rate [fee]="block?.extras?.medianFee" rounding="1.0-0"></app-fee-rate> <td>~<app-fee-rate [fee]="block.extras?.medianFee" rounding="1.0-0"></app-fee-rate>
<span class="fiat"> <span class="fiat">
<app-fiat [blockConversion]="blockConversion" [value]="block?.extras?.medianFee * 140" digitsInfo="1.2-2" <app-fiat [blockConversion]="blockConversion" [value]="block.extras?.medianFee * 140" digitsInfo="1.2-2"
i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes"
placement="bottom"></app-fiat> placement="bottom"></app-fiat>
</span> </span>
@ -259,7 +259,7 @@
</div> </div>
</div> </div>
<ng-template [ngIf]="!isLoadingBlock && !error"> <ng-template [ngIf]="block && !isLoadingBlock && !error">
<div [hidden]="!showDetails" id="details"> <div [hidden]="!showDetails" id="details">
<br> <br>

View File

@ -460,9 +460,9 @@ export class BlockComponent implements OnInit, OnDestroy {
inBlock[tx.txid] = true; inBlock[tx.txid] = true;
} }
blockAudit.feeDelta = blockAudit.expectedFees > 0 ? (blockAudit.expectedFees - (this.block.extras.totalFees + this.oobFees)) / blockAudit.expectedFees : 0; blockAudit.feeDelta = blockAudit.expectedFees > 0 ? (blockAudit.expectedFees - (this.block?.extras.totalFees + this.oobFees)) / blockAudit.expectedFees : 0;
blockAudit.weightDelta = blockAudit.expectedWeight > 0 ? (blockAudit.expectedWeight - this.block.weight) / blockAudit.expectedWeight : 0; blockAudit.weightDelta = blockAudit.expectedWeight > 0 ? (blockAudit.expectedWeight - this.block?.weight) / blockAudit.expectedWeight : 0;
blockAudit.txDelta = blockAudit.template.length > 0 ? (blockAudit.template.length - this.block.tx_count) / blockAudit.template.length : 0; blockAudit.txDelta = blockAudit.template.length > 0 ? (blockAudit.template.length - this.block?.tx_count) / blockAudit.template.length : 0;
this.blockAudit = blockAudit; this.blockAudit = blockAudit;
this.setAuditAvailable(true); this.setAuditAvailable(true);
} else { } else {

View File

@ -154,7 +154,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
}); });
} else { } else {
this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe( this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe(
tap((price) => this.transactions.forEach((tx) => tx['price'] = price)), tap((price) => this.transactions?.forEach((tx) => tx['price'] = price)),
).subscribe(); ).subscribe();
} }
} }
@ -239,7 +239,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
if (this.blockTime && this.transactions?.length && this.currency) { if (this.blockTime && this.transactions?.length && this.currency) {
this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe( this.priceService.getBlockPrice$(this.blockTime, true, this.currency).pipe(
tap((price) => this.transactions.forEach((tx) => tx['price'] = price)), tap((price) => this.transactions?.forEach((tx) => tx['price'] = price)),
).subscribe(); ).subscribe();
} }
const txIds = this.transactions.filter((tx) => !tx._outspends).map((tx) => tx.txid); const txIds = this.transactions.filter((tx) => !tx._outspends).map((tx) => tx.txid);