Skip to content

Commit

Permalink
enable filtered chain
Browse files Browse the repository at this point in the history
  • Loading branch information
codev911 committed Oct 18, 2024
1 parent f8d6955 commit 9bf36dd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
86 changes: 43 additions & 43 deletions lib/chain/parse.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,54 +111,54 @@ async function main() {
}
}

// const filteredChain: chain[] = [];

// for (let chainData of chainListDart) {
// console.log('filtering chain id:', chainData.chainId);

// const urls: string[] = [];
// const aggregateTest: any[] = [];
// let totalAccepted: number = 0;
// let totalRejected: number = 0;

// for (let url of chainData.urls) {
// aggregateTest.push(tryRpc(url));
// }

// const check = await Promise.allSettled(aggregateTest);

// for (let index = 0; index < chainData.urls.length; index++) {
// if (check[index].status === 'fulfilled') {
// urls.push(chainData.urls[index]);
// totalAccepted += 1;
// } else {
// totalRejected += 1;
// }
// }

// console.log(
// 'chain id:',
// chainData.chainId,
// 'approved',
// totalAccepted,
// 'rpcs and rejected',
// totalRejected,
// 'rpcs'
// );
// if (urls.length > 0) {
// filteredChain.push({
// chainId: chainData.chainId,
// name: chainData.name,
// urls: urls,
// });
// }
// }
const filteredChain: chain[] = [];

for (let chainData of chainListDart) {
console.log('filtering chain id:', chainData.chainId);

const urls: string[] = [];
const aggregateTest: any[] = [];
let totalAccepted: number = 0;
let totalRejected: number = 0;

for (let url of chainData.urls) {
aggregateTest.push(tryRpc(url));
}

const check = await Promise.allSettled(aggregateTest);

for (let index = 0; index < chainData.urls.length; index++) {
if (check[index].status === 'fulfilled') {
urls.push(chainData.urls[index]);
totalAccepted += 1;
} else {
totalRejected += 1;
}
}

console.log(
'chain id:',
chainData.chainId,
'approved',
totalAccepted,
'rpcs and rejected',
totalRejected,
'rpcs'
);
if (urls.length > 0) {
filteredChain.push({
chainId: chainData.chainId,
name: chainData.name,
urls: urls,
});
}
}

if (fs.existsSync(path.join(__dirname, 'list.chain.ts')) === false) {
fs.appendFileSync(
path.join(__dirname, 'list.chain.ts'),
'import { chain } from "lib/interface/chain.interface";\r\nexport const chainList: chain[] = ' +
JSON.stringify(chainListDart) +
JSON.stringify(filteredChain) +
';'
);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "live-evm-rpc",
"description": "Get Public Live EVM RPC url easily",
"author": "codev911",
"version": "1.2.3",
"version": "1.2.4",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down

0 comments on commit 9bf36dd

Please sign in to comment.