Skip to content

Commit 9e5d10b

Browse files
joostjagermononaut
andcommitted
Add average fee delta to pool ranking
Co-authored-by: mononaut <[email protected]>
1 parent 3d33233 commit 9e5d10b

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

backend/src/api/mining/mining.ts

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class Mining {
106106
emptyBlocks: emptyBlocksCount.length > 0 ? emptyBlocksCount[0]['count'] : 0,
107107
slug: poolInfo.slug,
108108
avgMatchRate: poolInfo.avgMatchRate !== null ? Math.round(100 * poolInfo.avgMatchRate) / 100 : null,
109+
avgFeeDelta: poolInfo.avgFeeDelta,
109110
};
110111
poolsStats.push(poolStat);
111112
});

backend/src/mempool.interfaces.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface PoolInfo {
1919
blockCount: number;
2020
slug: string;
2121
avgMatchRate: number | null;
22+
avgFeeDelta: number | null;
2223
}
2324

2425
export interface PoolStats extends PoolInfo {

backend/src/repositories/PoolsRepository.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class PoolsRepository {
3939
pools.name AS name,
4040
pools.link AS link,
4141
slug,
42-
AVG(blocks_audits.match_rate) AS avgMatchRate
42+
AVG(blocks_audits.match_rate) AS avgMatchRate,
43+
AVG((CAST(blocks.fees as SIGNED) - CAST(blocks_audits.expected_fees as SIGNED)) / NULLIF(CAST(blocks_audits.expected_fees as SIGNED), 0)) AS avgFeeDelta
4344
FROM blocks
4445
JOIN pools on pools.id = pool_id
4546
LEFT JOIN blocks_audits ON blocks_audits.height = blocks.height

frontend/src/app/components/pool-ranking/pool-ranking.component.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
<th class="" i18n="master-page.blocks">Blocks</th>
9595
<th *ngIf="auditAvailable" class="health text-right widget" i18n="latest-blocks.avg_health"
9696
i18n-ngbTooltip="latest-blocks.avg_health" ngbTooltip="Avg Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Avg Health</th>
97-
<th class="d-none d-md-table-cell" i18n="mining.empty-blocks">Empty blocks</th>
97+
<th *ngIf="auditAvailable" class="d-none d-sm-table-cell" i18n="mining.fees-per-block">Avg Block Fees</th>
98+
<th class="d-none d-lg-table-cell" i18n="mining.empty-blocks">Empty blocks</th>
9899
</tr>
99100
</thead>
100101
<tbody [attr.data-cy]="'pools-table'" *ngIf="(miningStatsObservable$ | async) as miningStats">
@@ -121,7 +122,15 @@
121122
<span class="health-badge badge badge-secondary" i18n="unknown">Unknown</span>
122123
</ng-template>
123124
</td>
124-
<td class="d-none d-md-table-cell">{{ pool.emptyBlocks }} ({{ pool.emptyBlockRatio }}%)</td>
125+
<td *ngIf="auditAvailable" class="d-none d-sm-table-cell">
126+
<span *ngIf="pool.avgFeeDelta != null; else nullFeeDelta" class="difference" [class.positive]="pool.avgFeeDelta >= 0" [class.negative]="pool.avgFeeDelta < 0">
127+
{{ pool.avgFeeDelta > 0 ? '+' : '' }}{{ (pool.avgFeeDelta * 100) | amountShortener: 2 }}%
128+
</span>
129+
<ng-template #nullFeeDelta>
130+
-
131+
</ng-template>
132+
</td>
133+
<td class="d-none d-lg-table-cell">{{ pool.emptyBlocks }} ({{ pool.emptyBlockRatio }}%)</td>
125134
</tr>
126135
<tr style="border-top: 1px solid #555">
127136
<td class="d-none d-md-table-cell"></td>

frontend/src/app/components/pool-ranking/pool-ranking.component.scss

+12-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,15 @@
110110
.disabled {
111111
pointer-events: none;
112112
opacity: 0.5;
113-
}
113+
}
114+
115+
td {
116+
.difference {
117+
&.positive {
118+
color: rgb(66, 183, 71);
119+
}
120+
&.negative {
121+
color: rgb(183, 66, 66);
122+
}
123+
}
124+
}

frontend/src/app/interfaces/node-api.interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface SinglePoolStats {
9191
logo: string;
9292
slug: string;
9393
avgMatchRate: number;
94+
avgFeeDelta: number;
9495
}
9596
export interface PoolsStats {
9697
blockCount: number;

0 commit comments

Comments
 (0)