Skip to content

Commit 322bc65

Browse files
committed
Display routes for volume chart instead of channels
1 parent 44c2d94 commit 322bc65

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

apps/frontend/src/components/bookkeeper/BkprRoot/BkprRoot.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ const Bookkeeper = () => {
145145
</Card.Header>
146146

147147
<Card.Body className="px-0 pt-0">
148-
Track channel routing performance.
148+
Track route performance.
149149
<VolumeInfo
150-
bestRoutingChannel={bookkeeperLandingData?.volumeSummary.mostTrafficChannel}
151-
worstRoutingChannel={bookkeeperLandingData?.volumeSummary.leastTrafficChannel}
150+
bestRoute={bookkeeperLandingData?.volumeSummary.mostTrafficRoute}
151+
worstRoute={bookkeeperLandingData?.volumeSummary.leastTrafficRoute}
152152
/>
153153
</Card.Body>
154154
<Card.Footer className="mt-3 mb-3 d-flex justify-content-end">

apps/frontend/src/components/bookkeeper/BkprRoot/VolumeInfo.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import React from 'react';
33
import './VolumeInfo.scss';
44

55
interface VolumeInfoProps {
6-
bestRoutingChannel?: string;
7-
worstRoutingChannel?: string;
6+
bestRoute?: string;
7+
worstRoute?: string;
88
}
99

10-
const VolumeInfo: React.FC<VolumeInfoProps> = ({ bestRoutingChannel, worstRoutingChannel }) => {
10+
const VolumeInfo: React.FC<VolumeInfoProps> = ({ bestRoute, worstRoute }) => {
1111
return (
1212
<>
1313
<div className="mt-3 d-flex flex-column align-items-start">
14-
<span className="fs-7 text-dark">Channel w/Most Traffic</span>
15-
<span className={`mt-1 fs-7 fw-bold best-channel`}>{bestRoutingChannel}</span>
14+
<span className="fs-7 text-dark">Route w/Most Traffic</span>
15+
<span className={`mt-1 fs-7 fw-bold best-channel`}>{bestRoute}</span>
1616
</div>
1717
<div className="mt-3 d-flex flex-column align-items-start">
18-
<span className="fs-7 text-dark">Channel w/Least Traffic</span>
19-
<span className={`mt-1 fs-7 fw-bold worst-channel`}>{worstRoutingChannel}</span>
18+
<span className="fs-7 text-dark">Route w/Least Traffic</span>
19+
<span className={`mt-1 fs-7 fw-bold worst-channel`}>{worstRoute}</span>
2020
</div>
2121
</>
2222
);

apps/frontend/src/hooks/use-http.ts

+33-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,38 @@ const useHttp = () => {
182182
const latestSatsFlowPeriod = satsFlowData.periods[satsFlowData.periods.length - 1];
183183
const inflowsThisMonth = latestSatsFlowPeriod.inflowSat;
184184
const outflowsThisMonth = latestSatsFlowPeriod.outflowSat;
185+
186+
let highestFee = 0;
187+
let highestForwardIndex: number | undefined = undefined;
188+
for (let i = 0; i < volumeData.forwards.length; i++) {
189+
if (volumeData.forwards[i].feeSat > highestFee) {
190+
highestFee = volumeData.forwards[i].feeSat;
191+
highestForwardIndex = i;
192+
} else {
193+
continue;
194+
}
195+
}
185196

197+
let lowestFee = Number.MAX_VALUE;
198+
let lowestForwardIndex: number | undefined = undefined;
199+
for (let i = 0; i < volumeData.forwards.length; i++) {
200+
if (volumeData.forwards[i].feeSat < lowestFee) {
201+
lowestFee = volumeData.forwards[i].feeSat;
202+
lowestForwardIndex = i;
203+
} else {
204+
continue;
205+
}
206+
}
207+
208+
let mostTrafficRoute = "";
209+
if (highestForwardIndex != null) {
210+
mostTrafficRoute = `${volumeData.forwards[highestForwardIndex].inboundChannelSCID} -> ${volumeData.forwards[highestForwardIndex].outboundChannelSCID}`;
211+
}
212+
213+
let worstTrafficRoute = "";
214+
if (lowestForwardIndex != null) {
215+
worstTrafficRoute = `${volumeData.forwards[lowestForwardIndex].outboundChannelSCID} -> ${volumeData.forwards[lowestForwardIndex].outboundChannelSCID}`;
216+
}
186217

187218
return {
188219
balanceSheetSummary: {
@@ -195,8 +226,8 @@ const useHttp = () => {
195226
outflows: outflowsThisMonth,
196227
},
197228
volumeSummary: {
198-
mostTrafficChannel: "best",
199-
leastTrafficChannel: "worst",
229+
mostTrafficRoute: mostTrafficRoute,
230+
leastTrafficRoute: worstTrafficRoute,
200231
}
201232
};
202233
};

apps/frontend/src/types/lightning-bookkeeper-landing.type.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type SatsFlowSummary = {
1616
};
1717

1818
export type VolumeSummary = {
19-
mostTrafficChannel: string;
20-
leastTrafficChannel: string;
19+
mostTrafficRoute: string;
20+
leastTrafficRoute: string;
2121
}
2222

0 commit comments

Comments
 (0)