Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Near: improve storage usage #76

Merged
merged 5 commits into from
Jun 8, 2023
Merged

Near: improve storage usage #76

merged 5 commits into from
Jun 8, 2023

Conversation

karim-en
Copy link
Collaborator

@karim-en karim-en commented May 29, 2023

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:

  • swap the keys for user_balances: LookupMap<AccountId, LookupMap<AccountId, u128>>
  • don't panic in 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.

@karim-en karim-en requested review from sept-en, olga24912 and UrAvgDeveloper and removed request for sept-en and olga24912 May 29, 2023 00:26
near/contracts/bridge/src/lib.rs Outdated Show resolved Hide resolved
@sept-en sept-en added the enhancement New feature or request label Jun 8, 2023
@sept-en sept-en merged commit 5ee143b into master Jun 8, 2023
@sept-en sept-en deleted the improve-storage-usage branch June 8, 2023 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants