From 6fe32cdd191259f53d95a3448ef912a6d319ed89 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 16 Jul 2023 18:24:42 +0900 Subject: [PATCH] [lightning] fix issue during initial node.features indexing --- backend/src/api/explorer/nodes.api.ts | 23 +++++++++++-------- .../app/lightning/node/node.component.html | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index 7d78559c4..22f9ca48a 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -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); diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index 0ed1c78c9..47b10184e 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -102,10 +102,10 @@ - + - +