Skip to content

Commit 455b577

Browse files
fix: gossip network_stats schema
1 parent 8402033 commit 455b577

File tree

2 files changed

+56
-21
lines changed

2 files changed

+56
-21
lines changed

src/api/entities.ts

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -565,33 +565,56 @@ export const epochSchema = z.discriminatedUnion("key", [
565565
]);
566566

567567
const gossipNetworkHealthSchema = z.object({
568-
rx_push_pct: z.number().optional(),
569-
duplicate_pct: z.number().optional(),
570-
bad_pct: z.number().optional(),
571-
pull_already_known_pct: z.number().optional(),
572-
total_stake: z.coerce.bigint(),
573-
total_peers: z.coerce.bigint(),
574-
connected_stake: z.coerce.bigint(),
575-
connected_peers: z.number(),
568+
push_rx_pct: z.number().nullable().optional(),
569+
pull_response_rx_pct: z.number().nullable().optional(),
570+
push_rx_dup_pct: z.number().nullable().optional(),
571+
pull_response_rx_dup_pct: z.number().nullable().optional(),
572+
push_rx_msg_bad_pct: z.number().nullable().optional(),
573+
push_rx_entry_bad_pct: z.number().nullable().optional(),
574+
pull_response_rx_msg_bad_pct: z.number().nullable().optional(),
575+
pull_response_rx_entry_bad_pct: z.number().nullable().optional(),
576+
pull_already_known_pct: z.number().nullable().optional(),
577+
total_stake: z.coerce.bigint().nullable().optional(),
578+
total_staked_peers: z.number().nullable().optional(),
579+
total_unstaked_peers: z.number().nullable().optional(),
580+
connected_stake: z.coerce.bigint().nullable().optional(),
581+
connected_staked_peers: z.number().nullable().optional(),
582+
connected_unstaked_peers: z.number().nullable().optional(),
576583
});
577584

578585
const gossipNetworkTrafficSchema = z.object({
579-
total_throughput: z.number().optional(),
580-
peer_names: z.string().array(),
581-
peer_throughputs: z.number().array().optional(),
586+
total_throughput: z.number().nullable().optional(),
587+
peer_names: z.string().array().nullable().optional(),
588+
peer_identities: z.string().array().nullable().optional(),
589+
peer_throughput: z.number().array().nullable().optional(),
582590
});
583591

584-
const gossipStorageUtilSchema = z.object({
585-
total_bytes: z.coerce.number(),
586-
peer_names: z.string().array(),
587-
peer_bytes: z.number().array(),
592+
const gossipStorageStatsSchema = z.object({
593+
capacity: z.number().nullable().optional(),
594+
expired_total: z.number().nullable().optional(),
595+
evicted_total: z.number().nullable().optional(),
596+
count: z.number().array().nullable().optional(),
597+
bps_tx: z.number().array().nullable().optional(),
598+
eps_tx: z.number().array().nullable().optional(),
599+
});
600+
601+
const gossipMessageStatsSchema = z.object({
602+
bytes_rx_total: z.number().array().nullable().optional(),
603+
count_rx_total: z.number().array().nullable().optional(),
604+
bytes_tx_total: z.number().array().nullable().optional(),
605+
count_tx_total: z.number().array().nullable().optional(),
606+
bps_rx: z.number().array().nullable().optional(),
607+
mps_rx: z.number().array().nullable().optional(),
608+
bps_tx: z.number().array().nullable().optional(),
609+
mps_tx: z.number().array().nullable().optional(),
588610
});
589611

590612
export const gossipNetworkStatsSchema = z.object({
591613
health: gossipNetworkHealthSchema,
592614
ingress: gossipNetworkTrafficSchema,
593615
egress: gossipNetworkTrafficSchema,
594-
storage: gossipStorageUtilSchema,
616+
storage: gossipStorageStatsSchema,
617+
messages: gossipMessageStatsSchema,
595618
});
596619

597620
export const gossipSchema = z.discriminatedUnion("key", [

src/features/StartupProgress/Firedancer/GossipProgress.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@ import { Card, Flex, Text } from "@radix-ui/themes";
22

33
import styles from "./gossip.module.css";
44
import { Bars } from "./Bars";
5+
import { useAtomValue } from "jotai";
6+
import { gossipNetworkStatsAtom } from "../../../api/atoms";
57

68
export function GossipProgress() {
7-
// TODO: use atom
9+
const networkStats = useAtomValue(gossipNetworkStatsAtom);
10+
if (!networkStats) return null;
11+
12+
const { health } = networkStats;
13+
814
return (
915
<Flex gapX="162px">
1016
<Flex direction="column" gap="20px">
1117
<Flex justify="between" gap="20px" align="stretch">
12-
<GossipCard title="Staked Peers" value={0} />
13-
<GossipCard title="Unstaked Peers" value={0} />
18+
<GossipCard
19+
title="Staked Peers"
20+
value={health.connected_staked_peers ?? null}
21+
/>
22+
<GossipCard
23+
title="Unstaked Peers"
24+
value={health.connected_unstaked_peers ?? null}
25+
/>
1426
<GossipCard title="Snapshot Peers" value={0} />
1527
</Flex>
1628

@@ -24,13 +36,13 @@ export function GossipProgress() {
2436

2537
interface GossipCardProps {
2638
title: string;
27-
value: number;
39+
value: number | null;
2840
}
2941
function GossipCard({ title, value }: GossipCardProps) {
3042
return (
3143
<Card className={styles.card}>
3244
<Text>{title}</Text>
33-
<Text className={styles.value}>{value}</Text>
45+
<Text className={styles.value}>{value ?? "--"}</Text>
3446
</Card>
3547
);
3648
}

0 commit comments

Comments
 (0)