WIP
This commit is contained in:
@@ -213,22 +213,38 @@ export const fetchNodes = async (): Promise<NodeData[]> => {
|
||||
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<IObservatoryNode[]> => {
|
||||
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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user