Basic block indexing WIP - Default mining pool icon - Only show mining hashrate on 1d scale

This commit is contained in:
nymkappa
2022-01-18 17:37:04 +09:00
parent b567c0ad43
commit 16ab9b38a0
12 changed files with 230 additions and 72 deletions

View File

@@ -50,7 +50,7 @@
<th class="d-none d-md-block" i18n="latest-blocks.height">Rank</th>
<th><!-- LOGO --></th>
<th i18n="latest-blocks.timestamp">Name</th>
<th i18n="latest-blocks.timestamp">Hashrate</th>
<th *ngIf="this.poolsWindowPreference === '1d'" i18n="latest-blocks.timestamp">Hashrate</th>
<th i18n="latest-blocks.mined">Block Count (%)</th>
<th class="d-none d-md-block" i18n="latest-blocks.transactions">Empty Blocks (%)</th>
</thead>
@@ -59,15 +59,15 @@
<td class="d-none d-md-block">-</td>
<td><!-- LOGO --></td>
<td>All miners</td>
<td>{{ miningStats.lastEstimatedHashrate}} PH/s</td>
<td *ngIf="this.poolsWindowPreference === '1d'">{{ miningStats.lastEstimatedHashrate}} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td>{{ miningStats.blockCount }}</td>
<td class="d-none d-md-block">{{ miningStats.totalEmptyBlock }} ({{ miningStats.totalEmptyBlockRatio }}%)</td>
</tr>
<tr *ngFor="let pool of miningStats.pools">
<td class="d-none d-md-block">{{ pool.rank }}</td>
<td><img width="25" height="25" src="{{ pool.logo }}"></td>
<td><img width="25" height="25" src="{{ pool.logo }}" onError="this.src = './resources/mining-pools/default.svg'"></td>
<td><a target="#" href="{{ pool.link }}">{{ pool.name }}</a></td>
<td>{{ pool.lastEstimatedHashrate }} PH/s</td>
<td *ngIf="this.poolsWindowPreference === '1d'">{{ pool.lastEstimatedHashrate }} {{ miningStats.miningUnits.hashrateUnit }}</td>
<td>{{ pool.blockCount }} ({{ pool.share }}%)</td>
<td class="d-none d-md-block">{{ pool.emptyBlocks }} ({{ pool.emptyBlockRatio }}%)</td>
</tr>

View File

@@ -2,10 +2,9 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { EChartsOption } from 'echarts';
import { BehaviorSubject, Subscription } from 'rxjs';
import { MiningStats } from 'src/app/interfaces/node-api.interface';
import { StateService } from 'src/app/services/state.service';
import { StorageService } from 'src/app/services/storage.service';
import { MiningService } from '../../services/mining.service';
import { MiningService, MiningStats } from '../../services/mining.service';
@Component({
selector: 'app-pool-ranking',
@@ -70,7 +69,7 @@ export class PoolRankingComponent implements OnInit, OnDestroy {
watchBlocks() {
this.blocksSubscription = this.stateService.blocks$
.subscribe(([block]) => {
.subscribe(() => {
if (!this.miningStats) {
return;
}
@@ -98,9 +97,14 @@ export class PoolRankingComponent implements OnInit, OnDestroy {
label: { color: '#FFFFFF' },
tooltip: {
formatter: () => {
return `<u><b>${pool.name}</b></u><br>` +
pool.lastEstimatedHashrate.toString() + ' PH/s (' + pool.share + `%)
<br>(` + pool.blockCount.toString() + ` blocks)`;
if (this.poolsWindowPreference === '1d') {
return `<u><b>${pool.name}</b></u><br>` +
pool.lastEstimatedHashrate.toString() + ' PH/s (' + pool.share + `%)
<br>(` + pool.blockCount.toString() + ` blocks)`;
} else {
return `<u><b>${pool.name}</b></u><br>` +
pool.blockCount.toString() + ` blocks`;
}
}
}
});
@@ -111,8 +115,8 @@ export class PoolRankingComponent implements OnInit, OnDestroy {
prepareChartOptions() {
this.chartOptions = {
title: {
text: 'Hashrate distribution',
subtext: 'Estimated from the # of blocks mined',
text: (this.poolsWindowPreference === '1d') ? 'Hashrate distribution' : 'Block distribution',
subtext: (this.poolsWindowPreference === '1d') ? 'Estimated from the # of blocks mined' : null,
left: 'center',
textStyle: {
color: '#FFFFFF',