Fix unnecessary cpfp 404 responses

This commit is contained in:
Mononaut
2023-03-06 00:02:21 -06:00
parent 5a09e3099c
commit 182cb16695
6 changed files with 33 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
import { Component, OnInit, Input, ChangeDetectionStrategy, OnChanges, Output, EventEmitter, ChangeDetectorRef } from '@angular/core';
import { StateService } from '../../services/state.service';
import { CacheService } from '../../services/cache.service';
import { Observable, ReplaySubject, BehaviorSubject, merge, Subscription } from 'rxjs';
import { Observable, ReplaySubject, BehaviorSubject, merge, Subscription, of } from 'rxjs';
import { Outspend, Transaction, Vin, Vout } from '../../interfaces/electrs.interface';
import { ElectrsApiService } from '../../services/electrs-api.service';
import { environment } from '../../../environments/environment';
@@ -23,6 +23,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
showMoreIncrement = 1000;
@Input() transactions: Transaction[];
@Input() cached: boolean = false;
@Input() showConfirmations = false;
@Input() transactionPage = false;
@Input() errorUnblinded = false;
@@ -67,7 +68,13 @@ export class TransactionsListComponent implements OnInit, OnChanges {
this.outspendsSubscription = merge(
this.refreshOutspends$
.pipe(
switchMap((txIds) => this.apiService.getOutspendsBatched$(txIds)),
switchMap((txIds) => {
if (!this.cached) {
return this.apiService.getOutspendsBatched$(txIds);
} else {
return of([]);
}
}),
tap((outspends: Outspend[][]) => {
if (!this.transactions) {
return;
@@ -155,7 +162,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
).subscribe();
});
const txIds = this.transactions.filter((tx) => !tx._outspends).map((tx) => tx.txid);
if (txIds.length) {
if (txIds.length && !this.cached) {
this.refreshOutspends$.next(txIds);
}
if (this.stateService.env.LIGHTNING) {