Skip to content

Commit 604ce9a

Browse files
feat: schedule strategy icons
1 parent 285060b commit 604ce9a

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

src/api/atoms.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
VoteDistance,
2323
BlockEngineUpdate,
2424
VoteBalance,
25+
ScheduleStrategy,
2526
} from "./types";
2627
import { rafAtom } from "../atomUtils";
2728

@@ -39,6 +40,10 @@ export const startupTimeAtom = atom<
3940

4041
export const tilesAtom = atom<Tile[] | undefined>(undefined);
4142

43+
export const scheduleStrategyAtom = atom<ScheduleStrategy | undefined>(
44+
undefined,
45+
);
46+
4247
export const identityBalanceAtom = atom<IdentityBalance | undefined>(undefined);
4348

4449
export const voteBalanceAtom = atom<VoteBalance | undefined>(undefined);

src/api/entities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export const identityKeySchema = z.string();
4646

4747
export const startupTimeNanosSchema = z.coerce.bigint();
4848

49+
export const scheduleStrategySchema = z.enum(["perf", "balanced", "revenue"]);
50+
export const ScheduleStrategyEnum = scheduleStrategySchema.enum;
51+
4952
export const tileTypeSchema = z.enum([
5053
"sock",
5154
"net",
@@ -306,6 +309,10 @@ export const summarySchema = z.discriminatedUnion("key", [
306309
key: z.literal("startup_time_nanos"),
307310
value: startupTimeNanosSchema,
308311
}),
312+
summaryTopicSchema.extend({
313+
key: z.literal("schedule_strategy"),
314+
value: scheduleStrategySchema,
315+
}),
309316
summaryTopicSchema.extend({
310317
key: z.literal("tiles"),
311318
value: tileSchema.array(),

src/api/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
voteStateSchema,
3939
slotTransactionsSchema,
4040
voteBalanceSchema,
41+
scheduleStrategySchema,
4142
} from "./entities";
4243

4344
export type Version = z.infer<typeof versionSchema>;
@@ -52,6 +53,8 @@ export type StartupTimeNanos = z.infer<typeof startupTimeNanosSchema>;
5253

5354
export type Tile = z.infer<typeof tileSchema>;
5455

56+
export type ScheduleStrategy = z.infer<typeof scheduleStrategySchema>;
57+
5558
export type IdentityBalance = z.infer<typeof identityBalanceSchema>;
5659

5760
export type VoteBalance = z.infer<typeof voteBalanceSchema>;

src/api/useSetAtomWsData.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
voteDistanceAtom,
2020
voteStateAtom,
2121
voteBalanceAtom,
22+
scheduleStrategyAtom,
2223
} from "./atoms";
2324
import {
2425
blockEngineSchema,
@@ -70,6 +71,7 @@ export function useSetAtomWsData() {
7071

7172
const setIdentityBalance = useSetAtom(identityBalanceAtom);
7273
const setVoteBalance = useSetAtom(voteBalanceAtom);
74+
const setScheduleStrategy = useSetAtom(scheduleStrategyAtom);
7375

7476
const [startupTime, setStartupTime] = useAtom(startupTimeAtom);
7577

@@ -196,6 +198,10 @@ export function useSetAtomWsData() {
196198
setTiles(value);
197199
break;
198200
}
201+
case "schedule_strategy": {
202+
setScheduleStrategy(value);
203+
break;
204+
}
199205
case "identity_balance": {
200206
setIdentityBalance(value);
201207
break;

src/features/Header/Cluster.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
clusterAtom,
55
versionAtom,
66
commitHashAtom,
7+
scheduleStrategyAtom,
78
} from "../../api/atoms";
89
import { Text, Tooltip } from "@radix-ui/themes";
910
import styles from "./cluster.module.css";
@@ -16,6 +17,7 @@ import { getClusterColor } from "./util";
1617
import { useMedia } from "react-use";
1718
import { BlockEngineUpdate } from "../../api/types";
1819
import { connectedColor, connectingColor, failureColor } from "../../colors";
20+
import { ScheduleStrategyEnum } from "../../api/entities";
1921

2022
export default function Cluster() {
2123
const cluster = useAtomValue(clusterAtom);
@@ -62,6 +64,8 @@ export default function Cluster() {
6264
</Tooltip>
6365

6466
<JitoIcon />
67+
68+
<StrategyIcon />
6569
</div>
6670
);
6771
}
@@ -128,3 +132,27 @@ function JitoIcon() {
128132
</Tooltip>
129133
);
130134
}
135+
136+
function StrategyIcon() {
137+
const scheduleStrategy = useAtomValue(scheduleStrategyAtom);
138+
139+
if (scheduleStrategy === ScheduleStrategyEnum.balanced) {
140+
return (
141+
<Tooltip content="Transaction scheduler strategy: balanced">
142+
<div>⚖️</div>
143+
</Tooltip>
144+
);
145+
} else if (scheduleStrategy === ScheduleStrategyEnum.perf) {
146+
return (
147+
<Tooltip content="Transaction scheduler strategy: performance">
148+
<div style={{ margin: "0 -2px" }}></div>
149+
</Tooltip>
150+
);
151+
} else if (scheduleStrategy === ScheduleStrategyEnum.revenue) {
152+
return (
153+
<Tooltip content="Transaction scheduler strategy: revenue">
154+
<div>📊</div>
155+
</Tooltip>
156+
);
157+
}
158+
}

0 commit comments

Comments
 (0)