Repost "want" after reconnect.
This commit is contained in:
parent
85c4a3480b
commit
0fad0fbb42
@ -13,7 +13,7 @@ export class AboutComponent implements OnInit {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.apiService.sendWebSocket({'action': 'want', data: []});
|
this.apiService.webSocketWant([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export class BlockchainComponent implements OnInit, OnDestroy {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.apiService.sendWebSocket({'action': 'want', data: ['stats', 'blocks', 'projected-blocks']});
|
this.apiService.webSocketWant(['stats', 'blocks', 'projected-blocks']);
|
||||||
|
|
||||||
this.txTrackingSubscription = this.memPoolService.txTracking$
|
this.txTrackingSubscription = this.memPoolService.txTracking$
|
||||||
.subscribe((response: ITxTracking) => {
|
.subscribe((response: ITxTracking) => {
|
||||||
@ -46,14 +46,14 @@ export class BlockchainComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.txTrackingLoading = true;
|
this.txTrackingLoading = true;
|
||||||
this.apiService.sendWebSocket({'action': 'track-tx', 'txId': txId});
|
this.apiService.webSocketStartTrackTx(txId);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.memPoolService.txIdSearch$
|
this.memPoolService.txIdSearch$
|
||||||
.subscribe((txId) => {
|
.subscribe((txId) => {
|
||||||
if (txId) {
|
if (txId) {
|
||||||
this.txTrackingLoading = true;
|
this.txTrackingLoading = true;
|
||||||
this.apiService.sendWebSocket({'action': 'track-tx', 'txId': txId});
|
this.apiService.webSocketStartTrackTx(txId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ const API_BASE_URL = '/api/v1';
|
|||||||
})
|
})
|
||||||
export class ApiService {
|
export class ApiService {
|
||||||
private websocketSubject: Observable<IMempoolDefaultResponse> = webSocket<IMempoolDefaultResponse | any>(WEB_SOCKET_URL);
|
private websocketSubject: Observable<IMempoolDefaultResponse> = webSocket<IMempoolDefaultResponse | any>(WEB_SOCKET_URL);
|
||||||
|
private lastWant: string[] | null = null;
|
||||||
|
private goneOffline = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
@ -27,7 +29,10 @@ export class ApiService {
|
|||||||
.pipe(
|
.pipe(
|
||||||
retryWhen((errors: any) => errors
|
retryWhen((errors: any) => errors
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(() => this.memPoolService.isOffline$.next(true)),
|
tap(() => {
|
||||||
|
this.goneOffline = true;
|
||||||
|
this.memPoolService.isOffline$.next(true);
|
||||||
|
}),
|
||||||
delay(5000),
|
delay(5000),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -92,17 +97,31 @@ export class ApiService {
|
|||||||
if (response['live-2h-chart']) {
|
if (response['live-2h-chart']) {
|
||||||
this.memPoolService.live2Chart$.next(response['live-2h-chart']);
|
this.memPoolService.live2Chart$.next(response['live-2h-chart']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.goneOffline === true) {
|
||||||
|
this.goneOffline = false;
|
||||||
|
if (this.lastWant) {
|
||||||
|
this.webSocketWant(this.lastWant);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(err: Error) => {
|
(err: Error) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
this.goneOffline = true;
|
||||||
console.log('Error, retrying in 10 sec');
|
console.log('Error, retrying in 10 sec');
|
||||||
setTimeout(() => this.startSubscription(), 10000);
|
setTimeout(() => this.startSubscription(), 10000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendWebSocket(data: any) {
|
webSocketStartTrackTx(txId: string) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.websocketSubject.next(data);
|
this.websocketSubject.next({'action': 'track-tx', 'txId': txId});
|
||||||
|
}
|
||||||
|
|
||||||
|
webSocketWant(data: string[]) {
|
||||||
|
// @ts-ignore
|
||||||
|
this.websocketSubject.next({'action': 'want', data: data});
|
||||||
|
this.lastWant = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
listTransactionsForBlock$(height: number): Observable<IBlockTransaction[]> {
|
listTransactionsForBlock$(height: number): Observable<IBlockTransaction[]> {
|
||||||
|
@ -154,10 +154,10 @@ export class StatisticsComponent implements OnInit {
|
|||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
this.spinnerLoading = true;
|
this.spinnerLoading = true;
|
||||||
if (this.radioGroupForm.controls['dateSpan'].value === '2h') {
|
if (this.radioGroupForm.controls['dateSpan'].value === '2h') {
|
||||||
this.apiService.sendWebSocket({'action': 'want', data: ['live-2h-chart']});
|
this.apiService.webSocketWant(['live-2h-chart']);
|
||||||
return this.apiService.list2HStatistics$();
|
return this.apiService.list2HStatistics$();
|
||||||
}
|
}
|
||||||
this.apiService.sendWebSocket({'action': 'want', data: ['']});
|
this.apiService.webSocketWant([]);
|
||||||
if (this.radioGroupForm.controls['dateSpan'].value === '24h') {
|
if (this.radioGroupForm.controls['dateSpan'].value === '24h') {
|
||||||
return this.apiService.list24HStatistics$();
|
return this.apiService.list24HStatistics$();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ export class TelevisionComponent implements OnInit {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.apiService.sendWebSocket({'action': 'want', data: ['projected-blocks', 'live-2h-chart']});
|
this.apiService.webSocketWant(['projected-blocks', 'live-2h-chart']);
|
||||||
|
|
||||||
const labelInterpolationFnc = (value: any, index: any) => {
|
const labelInterpolationFnc = (value: any, index: any) => {
|
||||||
return index % 6 === 0 ? formatDate(value, 'HH:mm', this.locale) : null;
|
return index % 6 === 0 ? formatDate(value, 'HH:mm', this.locale) : null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user