Minimize requests when node is not synchronized

This commit is contained in:
everoddandeven 2024-10-15 22:44:12 +02:00
parent 6caf8d2f2f
commit 96f0acad5a
4 changed files with 23 additions and 8 deletions

View file

@ -420,7 +420,7 @@ export class DaemonDataService {
await this.refreshMiningStatus(); await this.refreshMiningStatus();
await this.refreshMinerData(); if (this._daemonInfo.synchronized) await this.refreshMinerData();
this._gettingPeerList = true; this._gettingPeerList = true;
this._peerList = await this.daemonService.getPeerList(); this._peerList = await this.daemonService.getPeerList();

View file

@ -25,7 +25,14 @@ export class BlockchainComponent implements AfterViewInit {
return this.daemonData.lastBlockHeader; return this.daemonData.lastBlockHeader;
} }
public getLastBlockError: string = ''; public get daemonSynchronized(): boolean {
return this.daemonData.info ? this.daemonData.info.synchronized : false;
}
public get getLastBlockError(): string {
return this.daemonSynchronized ? '' : 'Last block header not available, blockchain is not synchronized';
}
public block?: Block; public block?: Block;
public getBlockByHash: boolean = false; public getBlockByHash: boolean = false;
public getBlockHash: string = ''; public getBlockHash: string = '';

View file

@ -13,7 +13,14 @@
<div *ngIf="daemonRunning && !daemonStopping" class="tab-content" id="pills-tabContent"> <div *ngIf="daemonRunning && !daemonStopping" class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-mining-status" role="tabpanel" aria-labelledby="pills-mining-status-tab" tabindex="0"> <div class="tab-pane fade show active" id="pills-mining-status" role="tabpanel" aria-labelledby="pills-mining-status-tab" tabindex="0">
<div *ngIf="miningStatusLoading"> <div *ngIf="coreBusy" class="alert alert-danger d-flex align-items-center justify-content-center text-center" role="alert">
<h4><i class="bi bi-exclamation-triangle m-2"></i></h4>&nbsp;&nbsp;
<div>
Mining status not available, node is not synchronized
</div>
</div>
<div *ngIf="!coreBusy && miningStatusLoading">
<!-- Placeholder per il caricamento --> <!-- Placeholder per il caricamento -->
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -31,7 +38,7 @@
</div> </div>
</div> </div>
<div *ngIf="miningStatus && miningStatus.active" class="card"> <div *ngIf="!coreBusy && miningStatus && miningStatus.active" class="card">
<div class="card-header bg-primary text-white"> <div class="card-header bg-primary text-white">
<h4>Mining Status</h4> <h4>Mining Status</h4>
</div> </div>
@ -78,7 +85,7 @@
</div> </div>
</div> </div>
<div *ngIf="miningStatus && !miningStatus.active" class="row g-5 p-2"> <div *ngIf="!coreBusy && miningStatus && !miningStatus.active" class="row g-5 p-2">
<div class="cold-md-7 col-lg-12"> <div class="cold-md-7 col-lg-12">
<div class="row gy-3"> <div class="row gy-3">
<h4 class="mb-3">Start mining on the daemon</h4> <h4 class="mb-3">Start mining on the daemon</h4>
@ -128,7 +135,7 @@
<div *ngIf="coreBusy" class="alert alert-danger d-flex align-items-center justify-content-center text-center" role="alert"> <div *ngIf="coreBusy" class="alert alert-danger d-flex align-items-center justify-content-center text-center" role="alert">
<h4><i class="bi bi-exclamation-triangle m-2"></i></h4>&nbsp;&nbsp; <h4><i class="bi bi-exclamation-triangle m-2"></i></h4>&nbsp;&nbsp;
<div> <div>
Core is busy: miner data is not available during blockchain sync Miner data is not available, node is not synchronized
</div> </div>
</div> </div>
@ -371,7 +378,7 @@
<hr class="my-4"> <hr class="my-4">
<button *ngIf="!submittingBlock" class="w-100 btn btn-primary btn-lg" type="button" (click)="submitBlock()">Submit Block</button> <button *ngIf="!submittingBlock" class="w-100 btn btn-primary btn-lg" type="button" (click)="submitBlock()" [disabled]="!validBlobData()">Submit Block</button>
<button *ngIf="submittingBlock" class="w-100 btn btn-primary btn-lg" type="button" disabled>Submitting Block ...</button> <button *ngIf="submittingBlock" class="w-100 btn btn-primary btn-lg" type="button" disabled>Submitting Block ...</button>
</div> </div>

View file

@ -16,8 +16,9 @@ import { DaemonDataService } from '../../core/services';
export class MiningComponent implements AfterViewInit { export class MiningComponent implements AfterViewInit {
public readonly navbarLinks: NavbarLink[]; public readonly navbarLinks: NavbarLink[];
public get coreBusy(): boolean { public get coreBusy(): boolean {
return this.daemonData.minerDataCoreBusyError; return this.daemonData.info? !this.daemonData.info.synchronized : true;
} }
public get miningStatus(): MiningStatus | undefined { public get miningStatus(): MiningStatus | undefined {