-
Notifications
You must be signed in to change notification settings - Fork 46
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
Change how chain links are stored #480
Comments
I highly agree with it. In my opinion, chain links should be isolated to the profile. It brings more flexibility to operate with chain link. And we can avoid the updating all chain links for profile when creating a new link as you said. |
As we did for |
@dadamu Are you currently working on this? If not, I might be able to pick it up in the next days before starting to review all the tests |
@RiccardoM Yes, I am working on it. |
Overview
When working towards #472, I realized that currently chain links are stored associated with a profile inside the
Profile
object itself. While this is very handy when querying them, the major downside is that when storing a chain link we need to update the whole profile. Since the gas usage is based on how much data is written during a transaction, this will cause later changes to the chain links slice to be extremely costly. Suppose we have a profile with already 10 links, if we add the 11th we need to write the whole slice again so we are writing 10 objects that we should not.Changes proposal
For the above reason, I think what we can do is change how chain links are stored by using the same method we use with other repeated data (eg: DTag requests, blocks, etc):
This would allow us to check the existence of a link in O(1) time as well as to query for such link in the same time.
If this is implemented, the
ProfileByChainLinkQuery
needs to be replaced with aUserChainLinks
paginated query.Please @dadamu @bragaz let me know what you think about this change.
The text was updated successfully, but these errors were encountered: