[lightning] fix issue during initial node.features indexing

This commit is contained in:
nymkappa 2023-07-16 18:24:42 +09:00
parent 8fb67a914c
commit 6fe32cdd19
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 15 additions and 12 deletions

View File

@ -80,17 +80,20 @@ class NodesApi {
// Features
node.features = JSON.parse(node.features);
let maxBit = 0;
for (const feature of node.features) {
maxBit = Math.max(maxBit, feature.bit);
node.featuresBits = null;
if (node.features) {
let maxBit = 0;
for (const feature of node.features) {
maxBit = Math.max(maxBit, feature.bit);
}
maxBit = Math.ceil(maxBit / 4) * 4 - 1;
node.featuresBits = new Array(maxBit + 1).fill(0);
for (const feature of node.features) {
node.featuresBits[feature.bit] = 1;
}
node.featuresBits = bin2hex(node.featuresBits.reverse().join(''));
}
maxBit = Math.ceil(maxBit / 4) * 4 - 1;
node.featuresBits = new Array(maxBit + 1).fill(0);
for (const feature of node.features) {
node.featuresBits[feature.bit] = 1;
}
node.featuresBits = bin2hex(node.featuresBits.reverse().join(''));
// Active channels and capacity
const activeChannelsStats: any = await this.$getActiveChannelsStats(public_key);

View File

@ -102,10 +102,10 @@
</td>
</ng-template>
</tr>
<tr *ngIf="node.geolocation">
<tr *ngIf="node.geolocation && node.featuresBits">
<ng-container *ngTemplateOutlet="featurebits;context:{bits: node.featuresBits}"></ng-container>
</tr>
<tr *ngIf="!node.geolocation" class="d-table-row d-md-none ">
<tr *ngIf="!node.geolocation && node.featuresBits" class="d-table-row d-md-none">
<ng-container *ngTemplateOutlet="featurebits;context:{bits: node.featuresBits}"></ng-container>
</tr>
</tbody>