From c7d61a3be41d236f7cef4fcb458d0668ba90f184 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Thu, 1 Dec 2022 11:34:11 +0900 Subject: [PATCH] only retry fetch CPFP for unconfirmed txs --- .../transaction/transaction.component.ts | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 3e04b0ad9..575c00637 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -7,10 +7,11 @@ import { catchError, retryWhen, delay, - map + map, + mergeMap } from 'rxjs/operators'; import { Transaction } from '../../interfaces/electrs.interface'; -import { of, merge, Subscription, Observable, Subject, timer, combineLatest, from } from 'rxjs'; +import { of, merge, Subscription, Observable, Subject, timer, combineLatest, from, throwError } from 'rxjs'; import { StateService } from '../../services/state.service'; import { WebsocketService } from '../../services/websocket.service'; import { AudioService } from '../../services/audio.service'; @@ -110,11 +111,24 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { switchMap((txId) => this.apiService .getCpfpinfo$(txId) - .pipe(retryWhen((errors) => errors.pipe(delay(2000)))) - ) + .pipe(retryWhen((errors) => errors.pipe( + mergeMap((error) => { + if (!this.tx?.status || this.tx.status.confirmed) { + return throwError(error); + } else { + return of(null); + } + }), + delay(2000) + ))) + ), + catchError(() => { + return of(null); + }) ) .subscribe((cpfpInfo) => { - if (!this.tx) { + if (!cpfpInfo || !this.tx) { + this.cpfpInfo = null; return; } if (cpfpInfo.effectiveFeePerVsize) {