refactor: cache VSS storeId by walletIndex#454
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds multi-wallet support to the VSS store ID provider by introducing a walletIndex parameter. The changes enable the system to cache and retrieve separate VSS store IDs for different wallet indices.
- Modified
VssStoreIdProviderto accept awalletIndexparameter and cache store IDs per wallet index - Updated
LightningServiceto pass thewalletIndexwhen retrieving VSS store ID - Added cache management methods to clear cached store IDs
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/src/main/java/to/bitkit/data/backup/VssStoreIdProvider.kt | Refactored from single cached value to map-based caching with wallet index support, added cache clearing methods |
| app/src/main/java/to/bitkit/services/LightningService.kt | Updated to pass walletIndex parameter when retrieving VSS store ID |
This change ensures that VSS store ID derivation maintains separate caches for each wallet index, preventing collisions when managing multiple wallets within the same application instance. Changes: - Replace single cachedStoreId with cachedStoreIds map keyed by walletIndex - Update getVssStoreId() to accept walletIndex parameter (defaults to 0) - Add clearCache() method to clear all cached store IDs - Add clearCache(walletIndex) method to clear cache for specific wallet - Update LightningService to pass walletIndex when getting store ID - Enhance logging to include walletIndex This matches the improvements from bitkit-ios PR #202, commit 91b47ba.
Changes: - Remove @volatile annotation (redundant with synchronized blocks) - Change cachedStoreIds from var to val (map reference never changes) - Move cache check inside synchronized block for proper thread-safety - MutableMap operations must be synchronized; @volatile only affects reference visibility This ensures all map operations happen under synchronization, preventing potential race conditions when multiple threads access the cache.
bb3863b to
0b3be33
Compare
jvsena42
reviewed
Nov 5, 2025
jvsena42
approved these changes
Nov 5, 2025
Member
jvsena42
left a comment
There was a problem hiding this comment.
Tested wipe and restore wallet on emulator
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
This PR ensures that VSS store ID derivation maintains separate caches for each wallet index, preventing collisions when managing multiple wallets within the same application instance.
Changes:
cachedStoreIdwith map keyed bywalletIndexgetVssStoreId()to acceptwalletIndexparameter (defaults to 0)clearCache()method to clear all cached store IDsclearCache(walletIndex)method to clear cache for specific walletLightningServiceto passwalletIndexwhen getting store IDwalletIndexVssBackupClient.setup()to acceptwalletIndexparameter (defaults to 0)vssStoreIdon wipeThis PR matches the improvements from synonymdev/bitkit-ios#202, commit 91b47ba.
Preview
n/a - refactor.
QA Notes
regressionTest wallet backup & restore.