Skip to content

Commit 79729fd

Browse files
authored
Implement statusById in grid proxy client, update NODE_INFO_CACHE, apply changes in playground (#4437)
1 parent c35f1b2 commit 79729fd

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

packages/gridproxy_client/src/modules/nodes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NodesBuilder, type NodesQuery } from "../builders/nodes";
2+
import { NodeStatus } from "../builders/public_api";
23
import { resolvePaginator } from "../utils";
34
import { AbstractClient } from "./abstract_client";
45
import type { Farm, FarmsClient } from "./farms";
@@ -11,6 +12,10 @@ export interface NodesExtractOptions {
1112
loadStats?: boolean;
1213
}
1314

15+
export interface NodeStatusInfo {
16+
status: NodeStatus;
17+
}
18+
1419
export class NodesClient extends AbstractClient<NodesBuilder, NodesQuery> {
1520
public farms: Map<number, Farm>;
1621
public twins: Map<number, Twin>;
@@ -89,6 +94,11 @@ export class NodesClient extends AbstractClient<NodesBuilder, NodesQuery> {
8994
return res.json();
9095
}
9196

97+
public async statusById(nodeId: number): Promise<NodeStatusInfo> {
98+
const res = await this.builder({}).build(`/nodes/${nodeId}/status`);
99+
return res.json();
100+
}
101+
92102
public async gpuById(nodeId: number): Promise<GPUCard[] | null | { error: string }> {
93103
const res = await this.builder({}).build(`/nodes/${nodeId}/gpu`);
94104
return res.json();

packages/playground/src/utils/contracts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { solutionType, type VDataTableHeader } from "@/types";
88
import { normalizeBalance } from "./helpers";
99

1010
// Cache to store results of `getNodeInfo` requests
11-
const NODE_INFO_CACHE: { [key: number]: { status: NodeStatus; farmId: number } } = {};
11+
const NODE_INFO_CACHE: { [key: number]: { status: NodeStatus } } = {};
1212

1313
export async function getUserContracts(grid: GridClient) {
1414
const res: any = await grid!.contracts.listMyContracts();
@@ -118,9 +118,9 @@ export async function getNodeInfo(nodeIDs: number[], requestedNodes: number[]) {
118118

119119
const resultPromises = nodeIDsToRequest.map(async nodeId => {
120120
if (typeof nodeId !== "number") return {};
121-
const nodeInfo = await gridProxyClient.nodes.byId(nodeId);
121+
const nodeStatusInfo = await gridProxyClient.nodes.statusById(nodeId);
122122
// Store result in cache
123-
NODE_INFO_CACHE[nodeId] = { status: nodeInfo.status, farmId: nodeInfo.farmId };
123+
NODE_INFO_CACHE[nodeId] = { status: nodeStatusInfo.status };
124124
return { [nodeId]: NODE_INFO_CACHE[nodeId] };
125125
});
126126

packages/playground/src/weblets/tf_contracts_list.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const password = ref("");
310310
const isValidForm = ref<boolean>(false);
311311
312312
const panel = ref<number[]>([0, 1, 2]);
313-
const nodeInfo: Ref<{ [nodeId: number]: { status: NodeStatus; farmId: number } }> = ref({});
313+
const nodeInfo: Ref<{ [nodeId: number]: { status: NodeStatus } }> = ref({});
314314
const unlockContractLoading = ref<boolean>(false);
315315
const contractsTable = ref<(typeof ContractsTable)[]>([]);
316316
const loadingLockDetails = ref(false);

0 commit comments

Comments
 (0)