Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/src/parts/checkpoints/Checkpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default function Checkpoints() {
if (!finalizedEpoch) return;
return finalizedEpoch;
}, [statusData]);
const latestRoot = useMemo(() => {
return statusData?.data?.finality?.finalized?.root;
}, [statusData]);

if (isLoading)
return (
Expand All @@ -48,6 +51,7 @@ export default function Checkpoints() {
<CheckpointsTable
slots={Object.values(data?.data?.slots ?? {})}
latestEpoch={latestEpoch}
latestRoot={latestRoot}
showCheckpoint={statusData?.data?.operating_mode === 'full'}
onSlotClick={setSlot}
/>
Expand Down
26 changes: 15 additions & 11 deletions web/src/parts/checkpoints/CheckpointsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { truncateHash } from '@utils';

export default function CheckpointsTable(props: {
latestEpoch?: string;
latestRoot?: string;
slots: APIBeaconSlot[];
onSlotClick?: (slot: APIBeaconSlot) => void;
showCheckpoint?: boolean;
Expand All @@ -27,6 +28,12 @@ export default function CheckpointsTable(props: {
);
});
}, [props.slots, search]);
const isServing = (slot: APIBeaconSlot) => {
if (props.latestRoot && slot.block_root) {
return slot.block_root === props.latestRoot;
}
return Boolean(props.latestEpoch && slot.epoch && slot.epoch === props.latestEpoch);
};
const onClick = (slot: APIBeaconSlot) => {
props.onSlotClick?.(slot);
};
Expand Down Expand Up @@ -112,20 +119,17 @@ export default function CheckpointsTable(props: {
<tr key={slot.slot}>
<td className="hidden sm:table-cell sm:pl-6 sm:px-2 drop-shadow-lg whitespace-nowrap py-2 font-semibold text-sm sm:text-base text-gray-100">
{slot.epoch}
{props.showCheckpoint &&
props.latestEpoch &&
slot.epoch &&
slot.epoch === props.latestEpoch && (
<img
className="hidden sm:inline-block w-5 pl-2 -mt-1"
src={FlagImage}
alt="Latest checkpoint"
/>
)}
{props.showCheckpoint && isServing(slot) && (
<img
className="hidden sm:inline-block w-5 pl-2 -mt-1"
src={FlagImage}
alt="Latest checkpoint"
/>
)}
</td>
<td className="whitespace-nowrap pl-2 sm:px-2 drop-shadow-lg sm:pl-0 py-2 font-semibold text-sm sm:text-base text-gray-100">
{slot.slot}
{props.latestEpoch && slot.epoch && slot.epoch === props.latestEpoch && (
{props.showCheckpoint && isServing(slot) && (
<img
className="sm:hidden w-5 inline-block pl-2 -mt-1"
src={FlagImage}
Expand Down
Loading