Skip to content

Commit

Permalink
chore: improve node health calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jul 10, 2024
1 parent 07ec579 commit a23511d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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;
}

0 comments on commit a23511d

Please sign in to comment.