Batch wallet coin balance fetches via getUserCoins#14136
Draft
dylanjeffers wants to merge 3 commits intomainfrom
Draft
Batch wallet coin balance fetches via getUserCoins#14136dylanjeffers wants to merge 3 commits intomainfrom
dylanjeffers wants to merge 3 commits intomainfrom
Conversation
Wallet rows called useFormattedCoinBalance per mint, each triggering getUserCoin. Reuse the paginated getUserCoins response (already fetched for the list) when aggregate balance is sufficient, with per-mint fallback if a mint is missing from the loaded page. Co-authored-by: Dylan Jeffers <dylanjeffers@users.noreply.github.com>
|
Export USER_COINS_WALLET_LIST_PARAMS and use the same limit/offset in WalletCoinsList, YourCoins, and useCoinBalance so React Query dedupes to a single getUserCoins request. Co-authored-by: Dylan Jeffers <dylanjeffers@users.noreply.github.com>
- Move getUserCoinQueryKey to userCoinQueryKey for reuse - After getUserCoins, prime per-mint userCoin cache (aggregate-only stub) - Route useUserCoin through batshit batcher so parallel mints coalesce - Revert useCoinBalance list override; wallet uses normal useUserCoin flow Co-authored-by: Dylan Jeffers <dylanjeffers@users.noreply.github.com>
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14136.audius.workers.dev Unique preview for this PR (deployed from this branch). |
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
Wallet rows were each calling
useUserCoin, which issued oneGET /v1/users/{id}/coins/{mint}per mint, even right afterGET /v1/users/{id}/coinsloaded the same balances.This update follows the collections-style pattern more closely:
Cache priming — When
useUserCoinscompletes, it callsprimeUserCoinQueriesFromList, which seeds each per-mintuseUserCoinquery key with aggregate fields from the list (balance,decimals, etc.) and emptyaccounts. Keys that already have data are left alone (so a fullgetUserCoinresponse is never overwritten). Child rows then read initialData from the cache while the batched detail fetch runs.Batcher —
useUserCoinnow usesgetUserCoinBatcher(batshitwindowScheduler(10)), so many mints requested in the same tick are deduped and fetched with parallelgetUserCoincalls inside one batch window, each result written back to the query cache.Reverted the
useCoinBalance/useFormattedCoinBalance“list override” API; the wallet list again uses the normaluseUserCoinpath.USER_COINS_WALLET_LIST_PARAMS(limit: 100) remains on walletuseUserCoinsso one stable query key is used.Test plan
getUserCoinrather than N unrelated timings.accountsafter fetch.getUserCoinQueryKeystill behave.