only retry fetch CPFP for unconfirmed txs

This commit is contained in:
Mononaut 2022-12-01 11:34:11 +09:00
parent 0b37a02435
commit c7d61a3be4
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -7,10 +7,11 @@ import {
catchError, catchError,
retryWhen, retryWhen,
delay, delay,
map map,
mergeMap
} from 'rxjs/operators'; } from 'rxjs/operators';
import { Transaction } from '../../interfaces/electrs.interface'; 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 { StateService } from '../../services/state.service';
import { WebsocketService } from '../../services/websocket.service'; import { WebsocketService } from '../../services/websocket.service';
import { AudioService } from '../../services/audio.service'; import { AudioService } from '../../services/audio.service';
@ -110,11 +111,24 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
switchMap((txId) => switchMap((txId) =>
this.apiService this.apiService
.getCpfpinfo$(txId) .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) => { .subscribe((cpfpInfo) => {
if (!this.tx) { if (!cpfpInfo || !this.tx) {
this.cpfpInfo = null;
return; return;
} }
if (cpfpInfo.effectiveFeePerVsize) { if (cpfpInfo.effectiveFeePerVsize) {