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

feat: add PluginStorageLib, AssociatedLinkedListSetLib #23

Merged

Conversation

jaypaik
Copy link
Collaborator

@jaypaik jaypaik commented Jan 10, 2024

Adding some libraries that help in accessing account associated storage in plugins.

Copy link
Contributor

@adam-alchemy adam-alchemy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for porting over to publish.

@jaypaik jaypaik merged commit 8b72c6d into main Jan 10, 2024
3 checks passed
@jaypaik jaypaik deleted the 01-10-feat_add_PluginStorageLib_AssociatedLinkedListSetLib branch January 10, 2024 17:59
Copy link
Contributor

@huaweigu huaweigu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to use any of these data structures in account storage?

}

/// @notice Removes a value from a set.
/// @dev This is an O(n) operation, where n is the number of elements in the set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We initially thought about using a linked list. It's also O(n) for deleting random item without knowing its previous item. (O(1) if previous item is known)
We then used a doubly linked list at the cost of storage. I guess it's a tradeoff.

/// @dev This is an O(n) operation, where n is the number of elements in the set.
/// @param set The set to get the elements of.
/// @return res An array of all elements in the set.
function getAll(AssociatedLinkedListSet storage set, address associated)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also implemented pagination, which was a nice feature from web2 APIs. But it's probably a overkill for most of accounts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants