parent
6b3e84255a
commit
0f611ecf8a
@ -10,8 +10,7 @@
|
|||||||
<ng-template [ngIf]="isLoading">
|
<ng-template [ngIf]="isLoading">
|
||||||
<div class="loading-block">
|
<div class="loading-block">
|
||||||
<h3>Waiting for blocks...</h3>
|
<h3>Waiting for blocks...</h3>
|
||||||
<br>
|
<div class="spinner-border text-light mt-2"></div>
|
||||||
<div class="spinner-border text-light"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-blockchain',
|
selector: 'app-blockchain',
|
||||||
templateUrl: './blockchain.component.html',
|
templateUrl: './blockchain.component.html',
|
||||||
styleUrls: ['./blockchain.component.scss']
|
styleUrls: ['./blockchain.component.scss']
|
||||||
})
|
})
|
||||||
export class BlockchainComponent implements OnInit {
|
export class BlockchainComponent implements OnInit, OnDestroy {
|
||||||
txTrackingLoading = false;
|
txTrackingLoading = false;
|
||||||
txShowTxNotFound = false;
|
txShowTxNotFound = false;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
subscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.stateService.blocks$.subscribe(() => this.isLoading = false);
|
this.subscription = this.stateService.isLoadingWebSocket$
|
||||||
|
.subscribe((isLoading) => this.isLoading = isLoading);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.stateService.blocks$
|
this.stateService.blocks$
|
||||||
.subscribe(([block]) => {
|
.subscribe(([block]) => {
|
||||||
if (block.matchRate >= 80 && !this.tabHidden) {
|
if (block.matchRate >= 66 && !this.tabHidden) {
|
||||||
this.blockIndex++;
|
this.blockIndex++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,6 +29,7 @@ export class StateService {
|
|||||||
txReplaced$ = new Subject<Transaction>();
|
txReplaced$ = new Subject<Transaction>();
|
||||||
mempoolTransactions$ = new Subject<Transaction>();
|
mempoolTransactions$ = new Subject<Transaction>();
|
||||||
blockTransactions$ = new Subject<Transaction>();
|
blockTransactions$ = new Subject<Transaction>();
|
||||||
|
isLoadingWebSocket$ = new ReplaySubject<boolean>(1);
|
||||||
|
|
||||||
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
||||||
|
|
||||||
|
@ -52,16 +52,17 @@ export class WebsocketService {
|
|||||||
|
|
||||||
this.startSubscription();
|
this.startSubscription();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startSubscription(retrying = false) {
|
startSubscription(retrying = false) {
|
||||||
|
this.stateService.isLoadingWebSocket$.next(true);
|
||||||
if (retrying) {
|
if (retrying) {
|
||||||
this.stateService.connectionState$.next(1);
|
this.stateService.connectionState$.next(1);
|
||||||
}
|
}
|
||||||
this.websocketSubject.next({'action': 'init'});
|
this.websocketSubject.next({'action': 'init'});
|
||||||
this.subscription = this.websocketSubject
|
this.subscription = this.websocketSubject
|
||||||
.subscribe((response: WebsocketResponse) => {
|
.subscribe((response: WebsocketResponse) => {
|
||||||
|
this.stateService.isLoadingWebSocket$.next(false);
|
||||||
if (response.blocks && response.blocks.length) {
|
if (response.blocks && response.blocks.length) {
|
||||||
const blocks = response.blocks;
|
const blocks = response.blocks;
|
||||||
blocks.forEach((block: Block) => {
|
blocks.forEach((block: Block) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user