Use new mempool position data for transaction ETA

This commit is contained in:
Mononaut 2023-05-03 10:30:45 -06:00
parent a22703d547
commit b79377d5a1
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 9 additions and 11 deletions

View File

@ -100,19 +100,19 @@
<tr *ngIf="!replaced && !isCached"> <tr *ngIf="!replaced && !isCached">
<td class="td-width" i18n="transaction.eta|Transaction ETA">ETA</td> <td class="td-width" i18n="transaction.eta|Transaction ETA">ETA</td>
<td> <td>
<ng-template [ngIf]="txInBlockIndex === undefined" [ngIfElse]="estimationTmpl"> <ng-template [ngIf]="this.mempoolPosition?.block == null" [ngIfElse]="estimationTmpl">
<span class="skeleton-loader"></span> <span class="skeleton-loader"></span>
</ng-template> </ng-template>
<ng-template #estimationTmpl> <ng-template #estimationTmpl>
<ng-template [ngIf]="txInBlockIndex >= 7" [ngIfElse]="belowBlockLimit"> <ng-template [ngIf]="this.mempoolPosition.block >= 7" [ngIfElse]="belowBlockLimit">
<span i18n="transaction.eta.in-several-hours|Transaction ETA in several hours or more">In several hours (or more)</span> <span i18n="transaction.eta.in-several-hours|Transaction ETA in several hours or more">In several hours (or more)</span>
</ng-template> </ng-template>
<ng-template #belowBlockLimit> <ng-template #belowBlockLimit>
<ng-template [ngIf]="network === 'liquid' || network === 'liquidtestnet'" [ngIfElse]="timeEstimateDefault"> <ng-template [ngIf]="network === 'liquid' || network === 'liquidtestnet'" [ngIfElse]="timeEstimateDefault">
<app-time kind="until" [time]="(60 * 1000 * txInBlockIndex) + now" [fastRender]="false" [fixedRender]="true"></app-time> <app-time kind="until" [time]="(60 * 1000 * this.mempoolPosition.block) + now" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time>
</ng-template> </ng-template>
<ng-template #timeEstimateDefault> <ng-template #timeEstimateDefault>
<app-time kind="until" *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * txInBlockIndex) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time> <app-time kind="until" *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * this.mempoolPosition.block) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time>
</ng-template> </ng-template>
</ng-template> </ng-template>
</ng-template> </ng-template>

View File

@ -173,12 +173,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4);
if (!this.tx?.status?.confirmed) {
this.stateService.markBlock$.next({
txFeePerVSize: this.tx.effectiveFeePerVsize,
mempoolPosition: this.mempoolPosition,
});
}
this.cpfpInfo = cpfpInfo; this.cpfpInfo = cpfpInfo;
}); });
@ -241,6 +235,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.stateService.markBlock$.next({ this.stateService.markBlock$.next({
mempoolPosition: this.mempoolPosition mempoolPosition: this.mempoolPosition
}); });
this.txInBlockIndex = this.mempoolPosition.block;
} }
} else { } else {
this.mempoolPosition = null; this.mempoolPosition = null;
@ -430,7 +425,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
}); });
this.mempoolBlocksSubscription = this.stateService.mempoolBlocks$.subscribe((mempoolBlocks) => { this.mempoolBlocksSubscription = this.stateService.mempoolBlocks$.subscribe((mempoolBlocks) => {
if (!this.tx) { if (!this.tx || this.mempoolPosition) {
return; return;
} }
@ -506,6 +501,8 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.rbfInfo = null; this.rbfInfo = null;
this.rbfReplaces = []; this.rbfReplaces = [];
this.showCpfpDetails = false; this.showCpfpDetails = false;
this.txInBlockIndex = null;
this.mempoolPosition = null;
document.body.scrollTo(0, 0); document.body.scrollTo(0, 0);
this.leaveTransaction(); this.leaveTransaction();
} }
@ -587,6 +584,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.urlFragmentSubscription.unsubscribe(); this.urlFragmentSubscription.unsubscribe();
this.mempoolBlocksSubscription.unsubscribe(); this.mempoolBlocksSubscription.unsubscribe();
this.mempoolPositionSubscription.unsubscribe(); this.mempoolPositionSubscription.unsubscribe();
this.mempoolBlocksSubscription.unsubscribe();
this.leaveTransaction(); this.leaveTransaction();
} }
} }