From 1f4cf1710a65a0133554b006284e4c9b4c49c1ab Mon Sep 17 00:00:00 2001 From: nymkappa Date: Sat, 30 Apr 2022 17:19:03 +0900 Subject: [PATCH 1/2] Show getnetworkhashps core result in dashboard + update unit formatting --- backend/src/routes.ts | 1 + .../components/hashrate-chart/hashrate-chart.component.html | 3 +-- .../app/components/hashrate-chart/hashrate-chart.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/routes.ts b/backend/src/routes.ts index db5b4f05f..288e537c4 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -630,6 +630,7 @@ class Routes { res.json({ hashrates: hashrates, difficulty: difficulty, + currentHashrate: await bitcoinClient.getNetworkHashPs() }); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); diff --git a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html index b01a68dc4..4223eb50f 100644 --- a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html +++ b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html @@ -5,8 +5,7 @@
Hashrate

- {{ hashrates.currentHashrate | amountShortener }} - hashes/sec + {{ hashrates.currentHashrate | amountShortener: 1 : 'H/s' }}

diff --git a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts index 2a8419c24..af6c75765 100644 --- a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts +++ b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts @@ -125,7 +125,7 @@ export class HashrateChartComponent implements OnInit { return { blockCount: parseInt(response.headers.get('x-total-count'), 10), currentDifficulty: Math.round(data.difficulty[data.difficulty.length - 1].difficulty * 100) / 100, - currentHashrate: data.hashrates[data.hashrates.length - 1].avgHashrate, + currentHashrate: data.currentHashrate }; }), retryWhen((errors) => errors.pipe( From 3972e7b8f0de3f52c114ff872f6397f74ca2ff45 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Mon, 2 May 2022 17:39:03 +0900 Subject: [PATCH 2/2] Show current network hashrate and difficulty even if indexing is in progress --- backend/src/routes.ts | 3 ++- .../hashrate-chart/hashrate-chart.component.ts | 12 ++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/backend/src/routes.ts b/backend/src/routes.ts index 288e537c4..d27fab683 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -630,7 +630,8 @@ class Routes { res.json({ hashrates: hashrates, difficulty: difficulty, - currentHashrate: await bitcoinClient.getNetworkHashPs() + currentHashrate: await bitcoinClient.getNetworkHashPs(), + currentDifficulty: await bitcoinClient.getDifficulty(), }); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); diff --git a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts index af6c75765..e2c2e1db0 100644 --- a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts +++ b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts @@ -114,23 +114,15 @@ export class HashrateChartComponent implements OnInit { difficulty: diffFixed.map(val => [val.timestamp * 1000, val.difficulty]), }); this.isLoading = false; - - if (data.hashrates.length === 0) { - this.cd.markForCheck(); - throw new Error(); - } }), map((response) => { const data = response.body; return { blockCount: parseInt(response.headers.get('x-total-count'), 10), - currentDifficulty: Math.round(data.difficulty[data.difficulty.length - 1].difficulty * 100) / 100, - currentHashrate: data.currentHashrate + currentDifficulty: data.currentDifficulty, + currentHashrate: data.currentHashrate, }; }), - retryWhen((errors) => errors.pipe( - delay(60000) - )) ); }), share()