-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usdc: Add self rate limiting to the usdc attestation API. (#666)
## Motivation Circle's USDC attestation API has a 5 minute IP ban if rate limits are exceeded. In order to avoid the 5 minute ban we should proactively limit our requests to make sure this doesn't happen. ## Solution Use `golang.org/x/time/rate` to add rate limit calls to the USDC TokenDataReader. This PR makes the following changes to behavior: * If a 429 occurs and there is no Retry-After header, a 5 minute cooldown is triggered. This is to match the circle documentation. * If `usdc.ReadTokenData` is called back to back or concurrently, the first call will execute and the rest will delay according to an interval. The interval between calls is configurable. A new Json Spec parameter is introduced named `USDCConfig.AttestationAPIIntervalMilliseconds`
- Loading branch information
Showing
7 changed files
with
172 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters