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

feat: add exponential backoff factor for etherscan #288

Merged

Conversation

charles-cooper
Copy link
Member

What I did

How I did it

How to verify it

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

Copy link
Collaborator

@DanielSchiavini DanielSchiavini left a comment

Choose a reason for hiding this comment

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

This looks fine, but the retry logic is even mixed with the rest. We should really just have a @retry decorator

res = SESSION.get(uri, params=params)
res.raise_for_status()
data = res.json()
if not (data.get("status") == "0" and "rate limit" in data.get("result", "")):
break
sleep(backoff_ms / 1000)
backoff_factor = 1.1**i # 1.1**10 ~= 2.59
Copy link
Collaborator

Choose a reason for hiding this comment

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

better move the magic number to a constant or keyword arg

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm yea, i am planning to encapsulate the etherscan settings in a data structure, we can extract it into a kwarg then

@charles-cooper charles-cooper merged commit 3667459 into vyperlang:master Aug 28, 2024
9 checks passed
Leminkay pushed a commit to Leminkay/titanoboa that referenced this pull request Oct 28, 2024
* add slight exponential backoff factor for etherscan fetches
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