From 96f0acad5a89d57c7941bb9a2f756c49d28b262d Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Tue, 15 Oct 2024 22:44:12 +0200 Subject: [PATCH] Minimize requests when node is not synchronized --- .../core/services/daemon/daemon-data.service.ts | 2 +- .../pages/blockchain/blockchain.component.ts | 9 ++++++++- src/app/pages/mining/mining.component.html | 17 ++++++++++++----- src/app/pages/mining/mining.component.ts | 3 ++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index 584c840..8694192 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -420,7 +420,7 @@ export class DaemonDataService { await this.refreshMiningStatus(); - await this.refreshMinerData(); + if (this._daemonInfo.synchronized) await this.refreshMinerData(); this._gettingPeerList = true; this._peerList = await this.daemonService.getPeerList(); diff --git a/src/app/pages/blockchain/blockchain.component.ts b/src/app/pages/blockchain/blockchain.component.ts index bf2ce46..09dc6b9 100644 --- a/src/app/pages/blockchain/blockchain.component.ts +++ b/src/app/pages/blockchain/blockchain.component.ts @@ -25,7 +25,14 @@ export class BlockchainComponent implements AfterViewInit { 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 getBlockByHash: boolean = false; public getBlockHash: string = ''; diff --git a/src/app/pages/mining/mining.component.html b/src/app/pages/mining/mining.component.html index 8772392..66dfda7 100644 --- a/src/app/pages/mining/mining.component.html +++ b/src/app/pages/mining/mining.component.html @@ -13,7 +13,14 @@

Mining

-
+ + +
@@ -31,7 +38,7 @@
-
+

Mining Status

@@ -78,7 +85,7 @@
{{ miningStatus.active ? 'Mining Active' : 'Mining Inacti
-
+

Start mining on the daemon

@@ -128,7 +135,7 @@

Necessary data to create a custom block template, used by p2poo @@ -371,7 +378,7 @@

Submit a mined block to the network


- +
diff --git a/src/app/pages/mining/mining.component.ts b/src/app/pages/mining/mining.component.ts index 08d0311..aa30762 100644 --- a/src/app/pages/mining/mining.component.ts +++ b/src/app/pages/mining/mining.component.ts @@ -16,8 +16,9 @@ import { DaemonDataService } from '../../core/services'; export class MiningComponent implements AfterViewInit { public readonly navbarLinks: NavbarLink[]; + public get coreBusy(): boolean { - return this.daemonData.minerDataCoreBusyError; + return this.daemonData.info? !this.daemonData.info.synchronized : true; } public get miningStatus(): MiningStatus | undefined {