Merge pull request #4929 from mempool/mononaut/fix-acc-rate-labels

Fix accelerated rate labels
This commit is contained in:
wiz 2024-04-08 23:13:20 +09:00 committed by GitHub
commit b74b8a8a5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 5 deletions

View File

@ -976,6 +976,9 @@ class Blocks {
if (this.blocks.length > config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4) { if (this.blocks.length > config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4) {
this.blocks = this.blocks.slice(-config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4); this.blocks = this.blocks.slice(-config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4);
} }
blockSummary.transactions.forEach(tx => {
delete tx.acc;
});
this.blockSummaries.push(blockSummary); this.blockSummaries.push(blockSummary);
if (this.blockSummaries.length > config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4) { if (this.blockSummaries.length > config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4) {
this.blockSummaries = this.blockSummaries.slice(-config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4); this.blockSummaries = this.blockSummaries.slice(-config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 4);
@ -1119,6 +1122,7 @@ class Blocks {
} }
return { return {
txid: tx.txid, txid: tx.txid,
time: tx.firstSeen,
fee: tx.fee || 0, fee: tx.fee || 0,
vsize: tx.vsize, vsize: tx.vsize,
value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0)), value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0)),

View File

@ -561,13 +561,13 @@
<ng-template #gogglesRow> <ng-template #gogglesRow>
@if (!isLoadingTx) { @if (!isLoadingTx) {
@if (((auditStatus && auditStatus.accelerated) || accelerationInfo || (tx && tx.acceleration)) || filters.length) { @if (isAcceleration || filters.length) {
<tr> <tr>
<td class="td-width"> <td class="td-width">
<span class="goggles-icon"><app-svg-images name="goggles" width="100%" height="100%"></app-svg-images></span> <span class="goggles-icon"><app-svg-images name="goggles" width="100%" height="100%"></app-svg-images></span>
</td> </td>
<td class="wrap-cell"> <td class="wrap-cell">
@if ((auditStatus && auditStatus.accelerated) || accelerationInfo || (tx && tx.acceleration)) { @if (isAcceleration) {
<span class="badge badge-accelerated mr-1" i18n="transaction.audit.accelerated">Accelerated</span> <span class="badge badge-accelerated mr-1" i18n="transaction.audit.accelerated">Accelerated</span>
} }
<ng-container *ngFor="let filter of filters;"> <ng-container *ngFor="let filter of filters;">
@ -613,7 +613,7 @@
@if (!isLoadingTx) { @if (!isLoadingTx) {
@if ((cpfpInfo && hasEffectiveFeeRate) || accelerationInfo) { @if ((cpfpInfo && hasEffectiveFeeRate) || accelerationInfo) {
<tr> <tr>
@if (tx.acceleration || accelerationInfo) { @if (isAcceleration) {
<td i18n="transaction.accelerated-fee-rate|Accelerated transaction fee rate">Accelerated fee rate</td> <td i18n="transaction.accelerated-fee-rate|Accelerated transaction fee rate">Accelerated fee rate</td>
} @else { } @else {
<td i18n="transaction.effective-fee-rate|Effective transaction fee rate">Effective fee rate</td> <td i18n="transaction.effective-fee-rate|Effective transaction fee rate">Effective fee rate</td>

View File

@ -9,7 +9,8 @@ import {
delay, delay,
mergeMap, mergeMap,
tap, tap,
map map,
retry
} from 'rxjs/operators'; } from 'rxjs/operators';
import { Transaction } from '../../interfaces/electrs.interface'; import { Transaction } from '../../interfaces/electrs.interface';
import { of, merge, Subscription, Observable, Subject, from, throwError, combineLatest } from 'rxjs'; import { of, merge, Subscription, Observable, Subject, from, throwError, combineLatest } from 'rxjs';
@ -93,6 +94,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
adjustedVsize: number | null; adjustedVsize: number | null;
pool: Pool | null; pool: Pool | null;
auditStatus: AuditStatus | null; auditStatus: AuditStatus | null;
isAcceleration: boolean = false;
filters: Filter[] = []; filters: Filter[] = [];
showCpfpDetails = false; showCpfpDetails = false;
fetchCpfp$ = new Subject<string>(); fetchCpfp$ = new Subject<string>();
@ -287,6 +289,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
filter(() => this.stateService.env.ACCELERATOR === true), filter(() => this.stateService.env.ACCELERATOR === true),
tap(() => { tap(() => {
this.accelerationInfo = null; this.accelerationInfo = null;
this.setIsAccelerated();
}), }),
switchMap((blockHeight: number) => { switchMap((blockHeight: number) => {
return this.servicesApiService.getAccelerationHistory$({ blockHeight }); return this.servicesApiService.getAccelerationHistory$({ blockHeight });
@ -302,6 +305,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
acceleration.boost = boostCost; acceleration.boost = boostCost;
this.accelerationInfo = acceleration; this.accelerationInfo = acceleration;
this.setIsAccelerated();
} }
} }
}); });
@ -322,6 +326,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
map(block => { map(block => {
return block.extras.pool; return block.extras.pool;
}), }),
retry({ count: 3, delay: 2000 }),
catchError(() => { catchError(() => {
return of(null); return of(null);
}) })
@ -342,18 +347,21 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
accelerated: isAccelerated, accelerated: isAccelerated,
}; };
}), }),
retry({ count: 3, delay: 2000 }),
catchError(() => { catchError(() => {
return of(null); return of(null);
}) })
) : of(isCoinbase ? { coinbase: true } : null) ) : of(isCoinbase ? { coinbase: true } : null)
]); ]);
}), }),
catchError(() => { catchError((e) => {
return of(null); return of(null);
}) })
).subscribe(([pool, auditStatus]) => { ).subscribe(([pool, auditStatus]) => {
this.pool = pool; this.pool = pool;
this.auditStatus = auditStatus; this.auditStatus = auditStatus;
this.setIsAccelerated();
}); });
this.mempoolPositionSubscription = this.stateService.mempoolTxPosition$.subscribe(txPosition => { this.mempoolPositionSubscription = this.stateService.mempoolTxPosition$.subscribe(txPosition => {
@ -680,6 +688,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
} }
if (cpfpInfo.acceleration) { if (cpfpInfo.acceleration) {
this.tx.acceleration = cpfpInfo.acceleration; this.tx.acceleration = cpfpInfo.acceleration;
this.setIsAccelerated();
} }
this.cpfpInfo = cpfpInfo; this.cpfpInfo = cpfpInfo;
@ -691,6 +700,11 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.hasEffectiveFeeRate = hasRelatives || (this.tx.effectiveFeePerVsize && (Math.abs(this.tx.effectiveFeePerVsize - this.tx.feePerVsize) > 0.01)); this.hasEffectiveFeeRate = hasRelatives || (this.tx.effectiveFeePerVsize && (Math.abs(this.tx.effectiveFeePerVsize - this.tx.feePerVsize) > 0.01));
} }
setIsAccelerated() {
console.log(this.tx.acceleration, this.accelerationInfo, this.pool, this.accelerationInfo?.pools);
this.isAcceleration = (this.tx.acceleration || (this.accelerationInfo && this.pool && this.accelerationInfo.pools.some(pool => (pool === this.pool.id || pool?.['pool_unique_id'] === this.pool.id))));
}
setFeatures(): void { setFeatures(): void {
if (this.tx) { if (this.tx) {
this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit'); this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit');
@ -757,6 +771,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.pool = null; this.pool = null;
this.auditStatus = null; this.auditStatus = null;
document.body.scrollTo(0, 0); document.body.scrollTo(0, 0);
this.isAcceleration = false;
this.leaveTransaction(); this.leaveTransaction();
} }