core
core copied to clipboard
feat: token rates resumable polling
Explanation
Note: This PR accompanies https://github.com/MetaMask/metamask-extension/pull/23507. Read it for more context.
This PR changes the polling strategy for TokenRatesController.
I want to start/stop polling as metamask is opened/closed, to avoid unnecessary requests. But when it's re-opened, I want to "resume" polling rather than "restart".
e.g with a 3 minute polling interval:
-
it's been 12 hours since you last opened metamask, so fetch now.
-
it's been 1 minute since you last opened metamask, so schedule a fetch in 2 minutes.
I'm storing the last poll time so the interval can be maintained across starts/stops.
Open to alternatives and will write tests if concept ack.
References
Changelog
@metamask/package-a
- <CATEGORY>: Your change here
- <CATEGORY>: Your change here
@metamask/package-b
- <CATEGORY>: Your change here
- <CATEGORY>: Your change here
Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate