'use client';
import { AnimatedNumber } from '@/components/ui/AnimatedNumber';
import { fmt, fmtInt, fmtRatio } from '@/lib/format';
import { useLive } from '@/lib/live';
import { Time } from '@/lib/time';
import type { BgpStats } from '@/lib/types';
export function BgpLive({ initial }: { initial: BgpStats }) {
const live = useLive((s) => s.bgp);
const updates = useLive((s) => s.updates);
const cur = live ?? initial;
const ratioColor = (r: number) => (r >= 3 ? 'var(--p-high)' : r >= 1.5 ? 'var(--p-elevated)' : 'var(--ink)');
return (
{[
['updates / s', cur.updates_per_s, 1, undefined],
['announcements / s', cur.announcements_per_s, 1, `baseline ${fmt(initial.baseline.announcements_per_s, 0)}`],
['withdrawals / s', cur.withdrawals_per_s, 1, `baseline ${fmt(initial.baseline.withdrawals_per_s, 1)}`],
['unique prefixes / min', initial.unique_prefixes_1m, 0, undefined],
['unique origins / min', initial.unique_origins_1m, 0, undefined],
['origin changes / min', initial.origin_changes_1m, 0, undefined],
].map(([label, v, d, sub]) => (
- {label as string}
-
{sub ?
- {sub as string}
: null}
))}
announcements vs baseline {fmtRatio(cur.ratio.announcements)}
withdrawals vs baseline {fmtRatio(cur.ratio.withdrawals)}
{cur.fresh ? 'feed fresh' : 'feed stale — routing component frozen'}
{fmtInt(initial.peers)} peers ·
);
}