Skip to content

Commit 5190db8

Browse files
fix: gossip network_stats schema
1 parent f5d1230 commit 5190db8

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
@@ -563,33 +563,56 @@ export const epochSchema = z.discriminatedUnion("key", [
563563
]);
564564

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

576583
const gossipNetworkTrafficSchema = z.object({
577-
total_throughput: z.number().optional(),
578-
peer_names: z.string().array(),
579-
peer_throughputs: z.number().array().optional(),
584+
total_throughput: z.number().nullable().optional(),
585+
peer_names: z.string().array().nullable().optional(),
586+
peer_identities: z.string().array().nullable().optional(),
587+
peer_throughput: z.number().array().nullable().optional(),
580588
});
581589

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

588610
export const gossipNetworkStatsSchema = z.object({
589611
health: gossipNetworkHealthSchema,
590612
ingress: gossipNetworkTrafficSchema,
591613
egress: gossipNetworkTrafficSchema,
592-
storage: gossipStorageUtilSchema,
614+
storage: gossipStorageStatsSchema,
615+
messages: gossipMessageStatsSchema,
593616
});
594617

595618
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)