Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urls.ts now references *Server.json for return URL. #610

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 230 additions & 0 deletions helpers/mainServers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@

{
"name": "MainNet",
"pollTime": "5000",
"sites": [
{
"protocol": "https",
"url": "mainnet1.neo2.coz.io",
"location": "United States",
"port": "443",
"locale": "us",
"type": "RPC"
},
{
"protocol": "https",
"url": "mainnet2.neo2.coz.io",
"location": "United States",
"port": "443",
"locale": "us",
"type": "RPC"
},
{
"protocol": "https",
"url": "mainnet3.neo2.coz.io",
"location": "United States",
"port": "443",
"locale": "us",
"type": "RPC"
},
{
"protocol": "https",
"url": "node1.nl.neoblocks.org",
"location": "The Netherlands",
"port": "443",
"locale": "nl",
"type": "RPC"
},
{
"protocol": "https",
"url": "node2.nl.neoblocks.org",
"location": "The Netherlands",
"port": "443",
"locale": "nl",
"type": "RPC"
},
{
"service": "neoScan",
"url": "https://neoscan.io/api/main_net/v1/",
"location": "United States",
"address": "104.25.126.31",
"locale": "us",
"type": "REST"
},
{
"service": "PubSub",
"url": "wss://pubsub.main.neologin.io/",
"location": "Ireland",
"locale": "ie",
"type": "WebSockets"
},
{
"protocol": "https",
"url": "main.neologin.io",
"location": "Ireland",
"port": "443",
"locale": "ie",
"type": "RPC"
},
{
"protocol": "https",
"url": "seed1.switcheo.network",
"location": "Singapore",
"port": "10331",
"locale": "sg",
"type": "RPC"
},
{
"protocol": "https",
"url": "seed2.switcheo.network",
"location": "Singapore",
"port": "10331",
"locale": "sg",
"type": "RPC"
},
{
"protocol": "https",
"url": "seed3.switcheo.network",
"location": "Singapore",
"port": "10331",
"locale": "sg",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed1.ngd.network",
"location": "USA",
"locale": "us",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed2.ngd.network",
"location": "USA",
"locale": "us",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed3.ngd.network",
"location": "Hong Kong",
"locale": "hk",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed4.ngd.network",
"location": "Hong Kong",
"locale": "hk",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed5.ngd.network",
"location": "China",
"locale": "cn",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed6.ngd.network",
"location": "USA",
"locale": "us",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed7.ngd.network",
"location": "USA",
"locale": "us",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed8.ngd.network",
"location": "USA",
"locale": "us",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed9.ngd.network",
"location": "Hong Kong",
"locale": "hk",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed10.ngd.network",
"location": "Hong Kong",
"locale": "hk",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "seed.neoeconomy.io",
"location": "Canada",
"locale": "ca",
"port": "10332",
"type": "RPC"
},
{
"protocol": "http",
"url": "node1.edgeofneo.com",
"location": "France",
"locale": "fr",
"port": "10332",
"type": "RPC"
},
{
"protocol": "https",
"url": "explorer.o3node.org",
"location": "US",
"locale": "us",
"port": "443",
"type": "RPC"
},
{
"protocol": "https",
"url": "rpc1.go.nspcc.ru",
"location": "Russia",
"locale": "ru",
"port": "10331",
"type": "RPC"
},
{
"protocol": "https",
"url": "rpc2.go.nspcc.ru",
"location": "Russia",
"locale": "ru",
"port": "10331",
"type": "RPC"
},
{
"protocol": "https",
"url": "rpc3.go.nspcc.ru",
"location": "Canada",
"locale": "ca",
"port": "10331",
"type": "RPC"
},
{
"protocol": "https",
"url": "rpc4.go.nspcc.ru",
"location": "US",
"locale": "us",
"port": "10331",
"type": "RPC"
}
]
}
72 changes: 72 additions & 0 deletions helpers/testServers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

{
"name": "MainNet",
"pollTime": "5000",
"sites": [
{
"protocol": "https",
"url": "test1.cityofzion.io",
"port": "443"
},
{
"protocol": "https",
"url": "test2.cityofzion.io",
"port": "443"
},
{
"protocol": "https",
"url": "test3.cityofzion.io",
"port": "443"
},
{
"protocol": "http",
"url": "seed1.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed2.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed3.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed4.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed5.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed6.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed7.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed8.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed9.ngd.network",
"port": "20332"
},
{
"protocol": "http",
"url": "seed10.ngd.network",
"port": "20332"
}
]
}
56 changes: 14 additions & 42 deletions helpers/urls.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,33 @@
import { rpc } from "@cityofzion/neon-core";

const TESTNET_URLS = [
"https://test1.cityofzion.io:443",
"https://test2.cityofzion.io:443",
"https://test3.cityofzion.io:443",
"http://seed1.ngd.network:20332",
"http://seed2.ngd.network:20332",
"http://seed3.ngd.network:20332",
"http://seed4.ngd.network:20332",
"http://seed5.ngd.network:20332",
"http://seed6.ngd.network:20332",
"http://seed7.ngd.network:20332",
"http://seed8.ngd.network:20332",
"http://seed9.ngd.network:20332",
"http://seed10.ngd.network:20332",
];

const MAINNET_URLS = [
"http://seed1.ngd.network:10332",
"http://seed2.ngd.network:10332",
"http://seed3.ngd.network:10332",
"http://seed4.ngd.network:10332",
"http://seed5.ngd.network:10332",
"http://seed6.ngd.network:10332",
"http://seed7.ngd.network:10332",
"http://seed8.ngd.network:10332",
"http://seed9.ngd.network:10332",
"http://seed10.ngd.network:10332",
"https://seed0.cityofzion.io:443",
"https://seed1.cityofzion.io:443",
"https://seed2.cityofzion.io:443",
"https://seed3.cityofzion.io:443",
"https://seed4.cityofzion.io:443",
"https://seed5.cityofzion.io:443",
"https://seed6.cityofzion.io:443",
"https://seed7.cityofzion.io:443",
"https://seed8.cityofzion.io:443",
"https://seed9.cityofzion.io:443",
];

export function getUrls(net: string): string[] {
if (net === "TestNet") {
return TESTNET_URLS;
return parseJson(require("./testServers.json"));
} else if (net === "MainNet") {
return MAINNET_URLS;
return parseJson(require("./mainServers.json"));
} else {
throw new Error("Expected MainNet or TestNet");
}
}

function parseJson(jsonFile): string[] {
let returnArr = [];
let concatURL: string;
for (var i in jsonFile.sites) {
if (jsonFile.sites[i].protocol) {
concatURL = jsonFile.sites[i].protocol + "://" + jsonFile.sites[i].url + ":" +jsonFile.sites[i].port
returnArr.push(concatURL);
}
}
return returnArr;
};

function cutArray<T>(arr: T[]): T[] {
const randomStartIndex = Math.floor(Math.random() * arr.length);
return arr.slice(randomStartIndex).concat(arr.slice(0, randomStartIndex));
}
export async function getUrl(net: string): Promise<string> {
const orderedUrls = getUrls(net);

const slicedUrls = cutArray(orderedUrls);
let previousBlockCount = 0;
for (let i = 0; i < slicedUrls.length; i++) {
Expand Down