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.
The storage is used inefficiently for the balances in the fast bridge.
The first key of the struct
user_balances: LookupMap<AccountId, LookupMap<AccountId, u128>>
is the user account_id, and the second one is the token_account_id, so a new map is created for every user.Since the number of tokens is limited, then it is better to use the token_account_id as a first key.
Changes:
user_balances: LookupMap<AccountId, LookupMap<AccountId, u128>>
get_user_balance
Note: the storage migration of the contract struct is not needed but the existing
user_balances
should be cleared, this can be done to destroy the storage and redeploy or by implementing additional clear API.