From b9a047b22dc2f1a64fc336665f2a198639962d73 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Mon, 17 Jan 2022 15:34:34 +0900 Subject: [PATCH] Add difficulty adjustment in mining page + Fix pools table on mobile --- backend/src/api/mining.ts | 3 +- frontend/cypress/fixtures/pools.json | 4 +-- .../difficulty/difficulty.component.html | 11 +++++- .../difficulty/difficulty.component.ts | 10 ++++++ .../pool-ranking/pool-ranking.component.html | 35 +++++++++++-------- .../pool-ranking/pool-ranking.component.ts | 11 +++++- .../src/app/interfaces/node-api.interface.ts | 1 + frontend/src/app/services/mining.service.ts | 1 + .../src/resources/mining-pools/unknown.svg | 7 ++++ 9 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 frontend/src/resources/mining-pools/unknown.svg diff --git a/backend/src/api/mining.ts b/backend/src/api/mining.ts index 94d6c29a4..6582221a5 100644 --- a/backend/src/api/mining.ts +++ b/backend/src/api/mining.ts @@ -17,7 +17,8 @@ class Mining { public async $getPoolsStats(interval: string = "100 YEAR") : Promise { let poolsStatistics = {}; - const lastBlockHashrate = await this.bitcoinApi.$getEstimatedHashrate(717960); + const blockHeightTip = await this.bitcoinApi.$getBlockHeightTip(); + const lastBlockHashrate = await this.bitcoinApi.$getEstimatedHashrate(blockHeightTip); const poolsInfo: PoolInfo[] = await PoolsRepository.$getPoolsInfo(interval); const blockCount: number = await BlocksRepository.$blockCount(interval); const emptyBlocks: EmptyBlocks[] = await BlocksRepository.$countEmptyBlocks(interval); diff --git a/frontend/cypress/fixtures/pools.json b/frontend/cypress/fixtures/pools.json index 55c91a99a..1a69517e8 100644 --- a/frontend/cypress/fixtures/pools.json +++ b/frontend/cypress/fixtures/pools.json @@ -421,7 +421,7 @@ "link" : "http://www.dpool.top/" }, "/Rawpool.com/": { - "name" : "Rawpool.com", + "name" : "Rawpool", "link" : "https://www.rawpool.com/" }, "/haominer/": { @@ -947,7 +947,7 @@ "link" : "http://www.dpool.top/" }, "1FbBbv5oYqFKwiPm4CAqvAy8345n8AQ74b" : { - "name" : "Rawpool.com", + "name" : "Rawpool", "link" : "https://www.rawpool.com/" }, "1LsFmhnne74EmU4q4aobfxfrWY4wfMVd8w" : { diff --git a/frontend/src/app/components/difficulty/difficulty.component.html b/frontend/src/app/components/difficulty/difficulty.component.html index 5064c1c08..fc3030286 100644 --- a/frontend/src/app/components/difficulty/difficulty.component.html +++ b/frontend/src/app/components/difficulty/difficulty.component.html @@ -39,13 +39,22 @@ {{ epochData.previousRetarget | absolute | number: '1.2-2' }} % -
+
Current Period
{{ epochData.progress | number: '1.2-2' }} %
 
+
+
Next halving
+
+ + {{ i }} blocks + {{ i }} block +
+
+
diff --git a/frontend/src/app/components/difficulty/difficulty.component.ts b/frontend/src/app/components/difficulty/difficulty.component.ts index 312c1b2d0..ff44e5aeb 100644 --- a/frontend/src/app/components/difficulty/difficulty.component.ts +++ b/frontend/src/app/components/difficulty/difficulty.component.ts @@ -14,6 +14,8 @@ interface EpochProgress { timeAvg: string; remainingTime: number; previousRetarget: number; + blocksUntilHalving: number; + timeUntilHalving: number; } @Component({ @@ -26,6 +28,9 @@ export class DifficultyComponent implements OnInit { isLoadingWebSocket$: Observable; difficultyEpoch$: Observable; + @Input() showProgress: boolean = true; + @Input() showHalving: boolean = false; + constructor( public stateService: StateService, ) { } @@ -92,6 +97,9 @@ export class DifficultyComponent implements OnInit { colorPreviousAdjustments = '#ffffff66'; } + const blocksUntilHalving = block.height % 210000; + const timeUntilHalving = (blocksUntilHalving * timeAvgMins * 60 * 1000) + (now * 1000); + return { base: `${progress}%`, change, @@ -104,6 +112,8 @@ export class DifficultyComponent implements OnInit { newDifficultyHeight, remainingTime, previousRetarget, + blocksUntilHalving, + timeUntilHalving, }; }) ); diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.html b/frontend/src/app/components/pool-ranking/pool-ranking.component.html index cd47a8002..195f4b6f6 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.html +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.html @@ -1,6 +1,13 @@
+ + + +
+
+
+
+
-
@@ -38,33 +45,31 @@
-
-
-
-
- - - + + + - - + + - + + - + - - + + + - +
RankNameRankName HashrateBlock Count (share)Empty Blocks (ratio)Block Count (%)Empty Blocks (%)
-- All miners {{ miningStats.lastEstimatedHashrate}} PH/s {{ miningStats.blockCount }}{{ miningStats.totalEmptyBlock }} ({{ miningStats.totalEmptyBlockRatio }}%){{ miningStats.totalEmptyBlock }} ({{ miningStats.totalEmptyBlockRatio }}%)
{{ pool.rank }}{{ pool.name }}{{ pool.rank }}{{ pool.name }} {{ pool.lastEstimatedHashrate }} PH/s {{ pool.blockCount }} ({{ pool.share }}%){{ pool.emptyBlocks }} ({{ pool.emptyBlockRatio }}%){{ pool.emptyBlocks }} ({{ pool.emptyBlockRatio }}%)
diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts index a272a069f..8dc1ab0fc 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts @@ -93,7 +93,7 @@ export class PoolRankingComponent implements OnInit, OnDestroy { return; } data.push({ - value: pool.lastEstimatedHashrate, + value: pool.share, name: pool.name, label: { color: '#FFFFFF' }, tooltip: { @@ -125,8 +125,16 @@ export class PoolRankingComponent implements OnInit, OnDestroy { tooltip: { trigger: 'item' }, + legend: (window.innerWidth <= 767.98) ? { + bottom: '0%', + left: 'center', + textStyle: { + color: '#FFF' + } + } : null, series: [ { + top: '5%', name: 'Mining pool', type: 'pie', radius: ['30%', '70%'], @@ -137,6 +145,7 @@ export class PoolRankingComponent implements OnInit, OnDestroy { }, }, label: { + show: (window.innerWidth > 767.98), fontSize: 14, }, itemStyle: { diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 044d2f411..265ad59d9 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -62,6 +62,7 @@ export interface SinglePoolStats { share: string, lastEstimatedHashrate: string, emptyBlockRatio: string, + logo: string, } export interface PoolsStats { diff --git a/frontend/src/app/services/mining.service.ts b/frontend/src/app/services/mining.service.ts index 0989495c8..f388975a8 100644 --- a/frontend/src/app/services/mining.service.ts +++ b/frontend/src/app/services/mining.service.ts @@ -29,6 +29,7 @@ export class MiningService { share: (poolStat.blockCount / stats.blockCount * 100).toFixed(2), lastEstimatedHashrate: (poolStat.blockCount / stats.blockCount * stats.lastEstimatedHashrate / Math.pow(10, 15)).toFixed(2), emptyBlockRatio: (poolStat.emptyBlocks / poolStat.blockCount * 100).toFixed(2), + logo: `./resources/mining-pools/` + poolStat.name.toLowerCase().replace(' ', '').replace('.', '') + '.svg', ...poolStat } }); diff --git a/frontend/src/resources/mining-pools/unknown.svg b/frontend/src/resources/mining-pools/unknown.svg new file mode 100644 index 000000000..d6661188a --- /dev/null +++ b/frontend/src/resources/mining-pools/unknown.svg @@ -0,0 +1,7 @@ + + + + + + +