mirror of
https://github.com/mempool/mempool.git
synced 2025-02-22 14:22:44 +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() {
|
public async $getNodesAsShare() {
|
||||||
try {
|
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 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
|
GROUP BY as_number
|
||||||
ORDER BY COUNT(*) DESC
|
ORDER BY COUNT(DISTINCT nodes.public_key) DESC
|
||||||
`;
|
`;
|
||||||
const [nodesCountPerAS]: any = await DB.query(query);
|
const [nodesCountPerAS]: any = await DB.query(query);
|
||||||
|
|
||||||
|
@ -112,6 +114,7 @@ class NodesApi {
|
||||||
name: JSON.parse(as.names),
|
name: JSON.parse(as.names),
|
||||||
count: as.nodesCount,
|
count: as.nodesCount,
|
||||||
share: Math.floor(as.nodesCount / nodesWithAS[0].total * 10000) / 100,
|
share: Math.floor(as.nodesCount / nodesWithAS[0].total * 10000) / 100,
|
||||||
|
capacity: as.capacity,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,20 @@
|
||||||
<table class="table table-borderless text-center">
|
<table class="table table-borderless text-center">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="d-none d-md-block" i18n="mining.rank">Rank</th>
|
<th *ngIf="!isMobile()" i18n="mining.rank">Rank</th>
|
||||||
<th class="" i18n="lightning.as-name">Name</th>
|
<th i18n="lightning.as-name">Name</th>
|
||||||
<th class="" i18n="lightning.share">Hashrate</th>
|
<th *ngIf="!isMobile()" i18n="lightning.share">Share</th>
|
||||||
<th class="" i18n="lightning.nodes">Nodes</th>
|
<th i18n="lightning.nodes">Nodes</th>
|
||||||
|
<th i18n="lightning.capacity">Capacity</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody [attr.data-cy]="'pools-table'" *ngIf="(nodesPerAsObservable$ | async) as asList">
|
<tbody [attr.data-cy]="'pools-table'" *ngIf="(nodesPerAsObservable$ | async) as asList">
|
||||||
<tr *ngFor="let asEntry of 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="text-truncate" style="max-width: 100px">{{ asEntry.name }}</td>
|
||||||
<td class="">{{ asEntry.share }}%</td>
|
<td *ngIf="!isMobile()">{{ asEntry.share }}%</td>
|
||||||
<td class="">{{ asEntry.count }}</td>
|
<td>{{ asEntry.count }}</td>
|
||||||
|
<td><app-amount [satoshis]="asEntry.capacity" [digitsInfo]="'1.2-2'" [noFiat]="true"></app-amount></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { chartColors } from 'src/app/app.constants';
|
||||||
import { ApiService } from 'src/app/services/api.service';
|
import { ApiService } from 'src/app/services/api.service';
|
||||||
import { SeoService } from 'src/app/services/seo.service';
|
import { SeoService } from 'src/app/services/seo.service';
|
||||||
import { download } from 'src/app/shared/graphs.utils';
|
import { download } from 'src/app/shared/graphs.utils';
|
||||||
|
import { AmountShortenerPipe } from 'src/app/shared/pipes/amount-shortener.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-nodes-per-as-chart',
|
selector: 'app-nodes-per-as-chart',
|
||||||
|
@ -30,6 +31,7 @@ export class NodesPerAsChartComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private seoService: SeoService,
|
private seoService: SeoService,
|
||||||
|
private amountShortenerPipe: AmountShortenerPipe
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,9 @@ export class NodesPerAsChartComponent implements OnInit {
|
||||||
borderColor: '#000',
|
borderColor: '#000',
|
||||||
formatter: () => {
|
formatter: () => {
|
||||||
return `<b style="color: white">${as.name} (${as.share}%)</b><br>` +
|
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,
|
data: as.slug,
|
||||||
|
|
Loading…
Add table
Reference in a new issue