Add retry logic to acceleration data fetching on tx page

This commit is contained in:
natsoni 2024-07-10 23:22:57 +09:00
parent 645fd98c30
commit 4470461a98
No known key found for this signature in database
GPG key ID: C65917583181743B

View file

@ -317,11 +317,19 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.setIsAccelerated(); this.setIsAccelerated();
}), }),
switchMap((blockHeight: number) => { switchMap((blockHeight: number) => {
return this.servicesApiService.getAccelerationHistory$({ blockHeight }); return this.servicesApiService.getAccelerationHistory$({ blockHeight }).pipe(
switchMap((accelerationHistory: Acceleration[]) => {
if (this.tx.acceleration && !accelerationHistory.length) { // If the just mined transaction was accelerated, but services backend did not return any acceleration data, retry
return throwError('retry');
}
return of(accelerationHistory);
}), }),
retry({ count: 3, delay: 2000 }),
catchError(() => { catchError(() => {
return of([]); return of([]);
}) })
);
}),
).subscribe((accelerationHistory) => { ).subscribe((accelerationHistory) => {
for (const acceleration of accelerationHistory) { for (const acceleration of accelerationHistory) {
if (acceleration.txid === this.txId && (acceleration.status === 'completed' || acceleration.status === 'completed_provisional')) { if (acceleration.txid === this.txId && (acceleration.status === 'completed' || acceleration.status === 'completed_provisional')) {