Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Handle Paraswap rate limiting #168
Handle Paraswap rate limiting #168
Changes from 10 commits
4c8e396
e89df50
36bbf35
46692b2
7e71c5d
3d88f1a
8b75e0a
8e24d7a
508f656
67e496f
1e5c209
6c2851e
1d38b13
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use f64::powi or f64::powf instead of a loop. You can't get overflow panics with f64 because worst case it will stay at +INF.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid an overflow with Duration::mul_f64().
Being able to compute the correct factor to call
mul_f64()
only once wouldn't help us much if that would causemul_f64()
to panic because the result would overflowDuration
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a
checked_mul_f64
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be like
I see now that Duration for some reason doesn't have a non panicking version of mul_f64 which is weird. In this case I feel it is reasonable to extract the f64 out of the duration, do the math, put it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there is only checked_mul and saturating_mul which both require a u32 as the argument.
I could have made the
growth_factor
argument anu32
but that felt overly restrictive.But I don't feel strongly about that so I could change it if you'd like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't considered that before. Good idea. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of returning
None
, should we return the current backoff here, even if we don't increment the counter?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line with the comment above, we need some way to avoid printing duplicated messages.
In the first version of this implementation I logged messages while holding the
Mutex
lock. The code for that was way cleaner and easier to understand but also made the critical section super long.Now I only return
Some(Duration)
in case we actually increased the back off and therefore need a log message.