Skip to content

Add rpc load blance call helper #2876

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

noateden
Copy link
Contributor

Add a helper function help to balance and cache rpc calls

@g1nt0ki g1nt0ki self-requested a review April 13, 2025 11:16
helpers/rpc.ts Outdated
const GlobalEndpointsCooldown: { [key: string]: number } = {}

async function sleep(time: number) {
return new Promise((resolve) => setTimeout(resolve, time))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTimeout uses millisecond format iirc, so need to either *1000 here or send in ms in calls

Copy link
Member

@g1nt0ki g1nt0ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

helpers/rpc.ts Outdated

// anyway, sleep one second
await sleep(1)
} while(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I dont like the idea of infinitely looping till something works, sometimes the request is bad

helpers/rpc.ts Outdated

if (httpResponse.status === 200) {
return httpResponse.data
} else if (httpResponse.status >= 400 && httpResponse.status < 500) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, what if the request is bad, like we are requesting for token details of non existent token? we are punishing the endpoint for a bad request. maybe instead of immediately cooling down a endpoint, we see if some other endpoint gives 200 result and then add cooldown to bad endpoint based on their response/error code?

@noateden noateden requested a review from g1nt0ki April 15, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants