feat: add requestPeriodicUpdate method to SnapRegistryController#4043
Open
Mrtenz wants to merge 2 commits into
Open
feat: add requestPeriodicUpdate method to SnapRegistryController#4043Mrtenz wants to merge 2 commits into
requestPeriodicUpdate method to SnapRegistryController#4043Mrtenz wants to merge 2 commits into
Conversation
Adds a `periodicFetchThreshold` option (default 4 hours) and a `requestPeriodicUpdate` method that skips the update when the registry was fetched within that threshold, reducing unnecessary network requests while still keeping the database reasonably up to date.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4043 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 425 425
Lines 12364 12371 +7
Branches 1948 1950 +2
=======================================
+ Hits 12189 12196 +7
Misses 175 175 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6554437. Configure here.
Ensures callers can observe when `requestPeriodicUpdate` skips the fetch because the registry was recently fetched, consistent with the other early-exit paths in `#update`.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
Adds a
periodicFetchThresholdoption (default: 4 hours) and a publicrequestPeriodicUpdatemethod toSnapRegistryController.The new method is similar to
requestUpdate, but skips the update if the registry was fetched within the periodic threshold. This is useful for callers that want to keep the registry reasonably up to date on a longer interval (e.g., on wallet unlock) without triggering a fetch on every call.Note
Low Risk
Additive API around existing fetch/update paths; default thresholds and requestUpdate behavior are unchanged for messenger callers.
Overview
Adds a
periodicFetchThresholdconstructor option (default 4 hours) and a publicrequestPeriodicUpdate()onSnapRegistryControllerfor callers that want occasional registry refreshes (e.g. on wallet unlock) without hitting the network on every trigger.requestPeriodicUpdateno-ops whenlastUpdatedis within the periodic window—publishingregistryUpdatedwithfalseand skipping fetch—otherwise delegates torequestUpdate, which still uses the existing 5-minute recent-fetch guard inside#update.#wasRecentlyFetchednow accepts an optional threshold so the periodic path can reuse the same logic.Unit tests cover first fetch, skip within threshold, and refetch when stale. The method is not registered on the messenger (unlike
requestUpdate); consumers call it on the controller instance directly.Reviewed by Cursor Bugbot for commit 085669c. Bugbot is set up for automated code reviews on this repo. Configure here.