fix: use cached account for fetch accounts#82
Conversation
PR SummaryModified the wallet account fetching logic to preserve cached accounts when network requests return empty results, preventing account loss due to potential indexer latency issues. Added comprehensive logging to track cache loading and network fetch results across different blockchain networks. Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Commits Considered (1)
- df862a2: fix: use cached account for fetch accounts
Files Processed (2)
- Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt (3 hunks)
- Android/wallet/src/main/java/com/flow/wallet/wallet/KeyWallet.kt (2 hunks)
Actionable Comments (2)
-
Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt [196-197]
possible bug: "Cached accounts may not be preserved in new maps initialization."
-
Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt [211-216]
possible bug: "Cache preservation logic is incomplete."
Skipped Comments (0)
| val newAccounts = _accounts.toMutableMap() | ||
| val newFlowAccounts = flowAccounts.toMutableMap() |
There was a problem hiding this comment.
The initialization of newAccounts and newFlowAccounts creates mutable copies of the current state, but when network fetches return empty results, these copies won't contain the cached data. Consider initializing these maps with the existing cached data to ensure cached accounts are preserved.
| } else { | ||
| val cached = flowAccounts[network] | ||
| if (!cached.isNullOrEmpty()) { | ||
| Log.w("BaseWallet", "Network returned 0 accounts for $network, but cache has ${cached.size}. KEEPING CACHE due to potential indexer latency.") | ||
| } | ||
| } |
There was a problem hiding this comment.
The logic logs a warning about keeping cache but doesn't actually preserve the cached accounts in the newFlowAccounts and newAccounts maps. The cached data should be explicitly added to these maps to prevent account loss.
No description provided.