Skip to content

Commit

Permalink
chore: back to all settled
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Aug 19, 2024
1 parent d52e314 commit 938e148
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions types/rpc-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,8 @@ export class RPCService {
throw new Error(rpcUrl);
}
}
const promises = runtimeRpcs.map((rpcUrl) => requestEndpoint(rpcUrl));
// async function getFirstSuccessfulRequest(requests: string[]) {
// if (requests.length === 0) {
// throw new Error("All requests failed.");
// }
// const promisesToResolve = requests.map((rpcUrl) => requestEndpoint(rpcUrl));
//
// try {
// const res = await Promise.race(promisesToResolve);
// if (!res.success) {
// throw new Error(res.rpcUrl);
// }
// return res;
// } catch (err) {
// if (err instanceof Error && requests.includes(err.message)) {
// return getFirstSuccessfulRequest(requests.filter((request) => request !== err.message));
// }
// return getFirstSuccessfulRequest(requests.slice(1));
// }
// }
// const fastest = await getFirstSuccessfulRequest(runtimeRpcs);
//
// if (fastest.success) {
// latencies[`${networkId}__${fastest.rpcUrl}`] = fastest.duration;
// }

const promises = runtimeRpcs.map((rpcUrl) => requestEndpoint(rpcUrl));
const allResults = await Promise.allSettled(promises);

allResults.forEach((result) => {
Expand All @@ -96,6 +72,7 @@ export class RPCService {
}
}
});

return { latencies, runtimeRpcs };
}

Expand Down

0 comments on commit 938e148

Please sign in to comment.