Liquid unblinding: Replacing async/await with observable.

This commit is contained in:
softsimon
2021-08-18 14:05:40 +03:00
parent ef41334346
commit 2feb58eec7
2 changed files with 18 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ import {
map
} from 'rxjs/operators';
import { Transaction, Block } from '../../interfaces/electrs.interface';
import { of, merge, Subscription, Observable, Subject, timer, combineLatest, } from 'rxjs';
import { of, merge, Subscription, Observable, Subject, timer, combineLatest, from } from 'rxjs';
import { StateService } from '../../services/state.service';
import { WebsocketService } from '../../services/websocket.service';
import { AudioService } from 'src/app/services/audio.service';
@@ -154,21 +154,25 @@ export class TransactionComponent implements OnInit, OnDestroy {
transactionObservable$,
this.stateService.mempoolTransactions$
);
}),
switchMap((tx) => {
if (this.network === 'liquid') {
return from(this.liquidUnblinding.checkUnblindedTx(tx))
.pipe(
catchError((error) => {
this.errorUnblinded = error;
return of(tx);
})
)
}
return of(tx);
})
)
.subscribe(async (tx: Transaction) => {
.subscribe((tx: Transaction) => {
if (!tx) {
return;
}
if (this.network === 'liquid') {
try {
await this.liquidUnblinding.checkUnblindedTx(tx)
} catch (error) {
this.errorUnblinded = error;
}
}
this.tx = tx;
if (tx.fee === undefined) {
this.tx.fee = 0;