diff --git a/explorer-nextjs/src/app/api/index.tsx b/explorer-nextjs/src/app/api/index.tsx index ccb9a2797d..021b82bbd6 100644 --- a/explorer-nextjs/src/app/api/index.tsx +++ b/explorer-nextjs/src/app/api/index.tsx @@ -213,22 +213,38 @@ export const fetchNodes = async (): Promise => { return data; }; -export const fetchObservatoryNodes = async (): Promise< - IObservatoryNode[] | null -> => { - const response = await fetch(DATA_OBSERVATORY_NODES_URL, { - headers: { - Accept: "application/json", - "Content-Type": "application/json; charset=utf-8", - }, - }); +export const fetchObservatoryNodes = async (): Promise => { + const allNodes: IObservatoryNode[] = []; + let page = 1; + const PAGE_SIZE = 200; + let hasMoreData = true; - if (!response.ok) { - throw new Error("Failed to fetch observatory nodes"); + while (hasMoreData) { + const response = await fetch( + `${DATA_OBSERVATORY_NODES_URL}?page=${page}&limit=${PAGE_SIZE}`, + { + headers: { + Accept: "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + }, + ); + + if (!response.ok) { + throw new Error(`Failed to fetch observatory nodes (page ${page})`); + } + + const nodes: IObservatoryNode[] = await response.json(); + allNodes.push(...nodes); + + if (nodes.length < PAGE_SIZE) { + hasMoreData = false; // Stop fetching when the last page has fewer than 200 items + } else { + page++; // Move to the next page + } } - const nodes: IObservatoryNode[] = await response.json(); - return nodes; + return allNodes; }; // 🔹 Fetch NYM Price diff --git a/explorer-nextjs/src/app/api/urls.ts b/explorer-nextjs/src/app/api/urls.ts index 39adf2e9e7..a7807b73d7 100644 --- a/explorer-nextjs/src/app/api/urls.ts +++ b/explorer-nextjs/src/app/api/urls.ts @@ -16,7 +16,7 @@ export const NYM_PRICES_API = "https://api.nym.spectredao.net/api/v1/nym-price"; export const VALIDATOR_BASE_URL = process.env.NEXT_PUBLIC_VALIDATOR_URL || "https://rpc.nymtech.net"; export const DATA_OBSERVATORY_NODES_URL = - "https://api.nym.spectredao.net/api/v1/nodes?limit=5000"; + "https://api.nym.spectredao.net/api/v1/nodes"; export const DATA_OBSERVATORY_NODES_DELEGATIONS_URL = "https://api.nym.spectredao.net/api/v1/nodes"; export const DATA_OBSERVATORY_DELEGATIONS_URL = diff --git a/explorer-nextjs/src/components/landingPageComponents/NoiseCard.tsx b/explorer-nextjs/src/components/landingPageComponents/NoiseCard.tsx index 2a15d05934..1ef95f4400 100644 --- a/explorer-nextjs/src/components/landingPageComponents/NoiseCard.tsx +++ b/explorer-nextjs/src/components/landingPageComponents/NoiseCard.tsx @@ -49,8 +49,6 @@ export const NoiseCard = () => { return data.filter((entry) => new Date(entry.date_utc) >= cutoffDate); }; - console.log("filterData :>> ", filterData(data)); - const noiseLast24H = todaysData.total_packets_sent + todaysData.total_packets_received; const noisePrevious24H = @@ -61,7 +59,7 @@ export const NoiseCard = () => { throw new Error("Packets cannot be negative"); } - const BYTES_PER_PACKET = 2048; + const BYTES_PER_PACKET = (2413 + 386) / 2; const totalBytes = packets * BYTES_PER_PACKET; const units = ["B", "KB", "MB", "GB", "TB", "PB"];