From a23511df8951803590379b308bea802ade13a8cf Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Wed, 10 Jul 2024 12:10:12 +0700 Subject: [PATCH] chore: improve node health calculation --- frontend/src/screens/channels/Channels.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frontend/src/screens/channels/Channels.tsx b/frontend/src/screens/channels/Channels.tsx index 7b6c80e2..4ea07cf1 100644 --- a/frontend/src/screens/channels/Channels.tsx +++ b/frontend/src/screens/channels/Channels.tsx @@ -834,7 +834,6 @@ function getNodeHealth(channels: Channel[]) { const totalChannelCapacitySats = channels .map((channel) => (channel.localBalance + channel.remoteBalance) / 1000) .reduce((a, b) => a + b, 0); - const averageChannelBalance = channels .map((channel) => { @@ -851,15 +850,12 @@ function getNodeHealth(channels: Channel[]) { channels.map((channel) => channel.remotePubkey) ).size; - let nodeHealth = Math.ceil( - Math.min(3, numUniqueChannelPartners) * - (100 / 3) * // 3 channels is great + const nodeHealth = Math.ceil( + numUniqueChannelPartners * + (100 / 2) * // 2 or more channels is great (Math.min(totalChannelCapacitySats, 1_000_000) / 1_000_000) * // 1 million sats or more is great (0.9 + averageChannelBalance * 0.1) // +10% for perfectly balanced channels ); - // above calculation is a bit harsh - nodeHealth = Math.min(nodeHealth * 2, 100); - return nodeHealth; }