feat(settings): auto-sync RPCs by latency on first load#285
Merged
AugustoL merged 7 commits intoopenscan-explorer:devfrom Mar 9, 2026
Merged
feat(settings): auto-sync RPCs by latency on first load#285AugustoL merged 7 commits intoopenscan-explorer:devfrom
AugustoL merged 7 commits intoopenscan-explorer:devfrom
Conversation
Automatically tests and re-orders RPC endpoints by quality (privacy tier + latency) on first load, removing the need for manual sync. A rpcsSynced flag prevents re-running on every page load and is reset when the user clears cache data.
|
🚀 Preview: https://pr-285--openscan.netlify.app |
Collaborator
|
Re-checked the latest version of this PR after the follow-up commits. The main concerns I had before are now addressed:
At this point I think the tradeoff looks reasonable:
So from a performance / UX perspective, this looks good to me now. LGTM. |
MatiasOS
approved these changes
Mar 9, 2026
12 tasks
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.
Description
Automatically tests and re-orders RPC endpoints by latency and privacy tier on first load, so the best RPCs are always at the front without requiring manual action via the Settings sync button.
Related Issue
Type of Change
Changes Made
getPrivacyTierandsortRpcsByQualityfromsettings/index.tsxinto a new shared utilitysrc/utils/rpcAutoSync.tsautoSyncRpcs()function that tests all networks with ≥2 RPC endpoints in parallel and returns them sorted by qualitysrc/hooks/useRpcAutoSync.tshook that triggers auto-sync once on first load (whennetworksLoadingis false andrpcsSyncedis falsy)rpcsSynced?: booleantoUserSettingstype to persist the sync stateupdateSettings({ rpcsSynced: false })in the "Clear Cache Data" handler so the next load re-syncsuseRpcAutoSync()intoAppContentinApp.tsxBehavior
OPENSCAN_RPC_URLS_V3rewritten with sorted order;rpcsSynced: truesavedrpcsSynced: false→ next reload re-syncsrpcsSyncedNOT set (retries on next load)Checklist
npm run format:fixandnpm run lint:fixnpm run typecheckwith no errorsnpm run test:runAdditional Notes
The
syncedRefinuseRpcAutoSyncprevents a double-run in React StrictMode (which mounts effects twice in development).