mirror of
https://github.com/mempool/mempool.git
synced 2025-02-22 06:21:46 +01:00
Add capacity per AS
This commit is contained in:
parent
28cf0f71eb
commit
3edd6f23a5
3 changed files with 19 additions and 10 deletions
|
@ -96,10 +96,12 @@ class NodesApi {
|
|||
|
||||
public async $getNodesAsShare() {
|
||||
try {
|
||||
let query = `SELECT names, COUNT(*) as nodesCount from nodes
|
||||
let query = `SELECT names, COUNT(DISTINCT nodes.public_key) as nodesCount, SUM(capacity) as capacity
|
||||
FROM nodes
|
||||
JOIN geo_names ON geo_names.id = nodes.as_number
|
||||
JOIN channels ON channels.node1_public_key = nodes.public_key OR channels.node2_public_key = nodes.public_key
|
||||
GROUP BY as_number
|
||||
ORDER BY COUNT(*) DESC
|
||||
ORDER BY COUNT(DISTINCT nodes.public_key) DESC
|
||||
`;
|
||||
const [nodesCountPerAS]: any = await DB.query(query);
|
||||
|
||||
|
@ -112,6 +114,7 @@ class NodesApi {
|
|||
name: JSON.parse(as.names),
|
||||
count: as.nodesCount,
|
||||
share: Math.floor(as.nodesCount / nodesWithAS[0].total * 10000) / 100,
|
||||
capacity: as.capacity,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -21,18 +21,20 @@
|
|||
<table class="table table-borderless text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="d-none d-md-block" i18n="mining.rank">Rank</th>
|
||||
<th class="" i18n="lightning.as-name">Name</th>
|
||||
<th class="" i18n="lightning.share">Hashrate</th>
|
||||
<th class="" i18n="lightning.nodes">Nodes</th>
|
||||
<th *ngIf="!isMobile()" i18n="mining.rank">Rank</th>
|
||||
<th i18n="lightning.as-name">Name</th>
|
||||
<th *ngIf="!isMobile()" i18n="lightning.share">Share</th>
|
||||
<th i18n="lightning.nodes">Nodes</th>
|
||||
<th i18n="lightning.capacity">Capacity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody [attr.data-cy]="'pools-table'" *ngIf="(nodesPerAsObservable$ | async) as asList">
|
||||
<tr *ngFor="let asEntry of asList">
|
||||
<td class="d-none d-md-block">{{ asEntry.rank }}</td>
|
||||
<td *ngIf="!isMobile()">{{ asEntry.rank }}</td>
|
||||
<td class="text-truncate" style="max-width: 100px">{{ asEntry.name }}</td>
|
||||
<td class="">{{ asEntry.share }}%</td>
|
||||
<td class="">{{ asEntry.count }}</td>
|
||||
<td *ngIf="!isMobile()">{{ asEntry.share }}%</td>
|
||||
<td>{{ asEntry.count }}</td>
|
||||
<td><app-amount [satoshis]="asEntry.capacity" [digitsInfo]="'1.2-2'" [noFiat]="true"></app-amount></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -5,6 +5,7 @@ import { chartColors } from 'src/app/app.constants';
|
|||
import { ApiService } from 'src/app/services/api.service';
|
||||
import { SeoService } from 'src/app/services/seo.service';
|
||||
import { download } from 'src/app/shared/graphs.utils';
|
||||
import { AmountShortenerPipe } from 'src/app/shared/pipes/amount-shortener.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nodes-per-as-chart',
|
||||
|
@ -30,6 +31,7 @@ export class NodesPerAsChartComponent implements OnInit {
|
|||
constructor(
|
||||
private apiService: ApiService,
|
||||
private seoService: SeoService,
|
||||
private amountShortenerPipe: AmountShortenerPipe
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -89,7 +91,9 @@ export class NodesPerAsChartComponent implements OnInit {
|
|||
borderColor: '#000',
|
||||
formatter: () => {
|
||||
return `<b style="color: white">${as.name} (${as.share}%)</b><br>` +
|
||||
$localize`${as.count.toString()} nodes`;
|
||||
$localize`${as.count.toString()} nodes<br>` +
|
||||
$localize`${this.amountShortenerPipe.transform(as.capacity / 100000000, 2)} BTC capacity`
|
||||
;
|
||||
}
|
||||
},
|
||||
data: as.slug,
|
||||
|
|
Loading…
Add table
Reference in a new issue