Skip to content

Commit

Permalink
Get all access nodes while fetching them for the network
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Nov 1, 2023
1 parent e604bed commit 5907eae
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/grid_client/src/primitives/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ class Nodes {

async getAccessNodes(availableFor?: number): Promise<Record<string, unknown>> {
const accessNodes = {};
const nodes = await this.filterNodes({ accessNodeV4: true, accessNodeV6: true, availableFor });
for (const node of nodes) {
const ipv4 = node.publicConfig.ipv4;
const ipv6 = node.publicConfig.ipv6;
const domain = node.publicConfig.domain;
if (PrivateIp(ipv4.split("/")[0]) === false) {
accessNodes[+node.nodeId] = { ipv4: ipv4, ipv6: ipv6, domain: domain };
let nodes: NodeInfo[] = [];
let page = 1;
do {
nodes = await this.filterNodes({ accessNodeV4: true, accessNodeV6: true, availableFor, page });
for (const node of nodes) {
const ipv4 = node.publicConfig.ipv4;
const ipv6 = node.publicConfig.ipv6;
const domain = node.publicConfig.domain;
if (PrivateIp(ipv4.split("/")[0]) === false) {
accessNodes[+node.nodeId] = { ipv4: ipv4, ipv6: ipv6, domain: domain };
}
}
}
page++;
} while (nodes.length);
if (Object.keys(accessNodes).length === 0) {
throw Error("Couldn't find any node with public config");
}
Expand Down

0 comments on commit 5907eae

Please sign in to comment.