Skip to content

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
@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.

4 participants