Skip to content

Commit

Permalink
chore: minor improvements to node health indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jul 5, 2024
1 parent 64cd700 commit bd30cea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/ui/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const CircleProgress = React.forwardRef<
<ProgressPrimitive.Root
ref={ref}
className={cn(
`relative h-20 w-20 overflow-hidden rounded-full bg-primary/20 flex justify-center items-center`,
`relative h-20 w-20 overflow-hidden rounded-full flex justify-center items-center`,
className
)}
{...props}
style={{
background: `radial-gradient(closest-side, white 79%, transparent 80% 100%), conic-gradient(hsl(var(--primary)) ${value || 0}%, hsl(var(--secondary)) 0)`,
background: `radial-gradient(closest-side, hsl(var(--background)) 79%, transparent 80% 100%), conic-gradient(hsl(var(--primary)) ${value || 0}%, hsl(var(--secondary)) 0)`,
}}
>
{props.children || <div className="">{`${value || 0}%`}</div>}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,15 @@ function getNodeHealth(channels: Channel[]) {
channels.map((channel) => channel.remotePubkey)
).size;

const nodeHealth = Math.ceil(
let nodeHealth = Math.ceil(
Math.min(3, numUniqueChannelPartners) *
(100 / 3) * // 3 channels is great
(Math.min(totalChannelCapacitySats, 1_000_000) / 1_000_000) * // 1 million sats or more is great
averageChannelBalance // perfectly balanced is great!
);

// above calculation is a bit harsh
nodeHealth = Math.min(nodeHealth * 2, 100);

return nodeHealth;
}

0 comments on commit bd30cea

Please sign in to comment.