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: Custom StorageAccess implementation (packing) #25

Closed
enitrat opened this issue Jun 7, 2023 · 1 comment
Closed

feat: Custom StorageAccess implementation (packing) #25

enitrat opened this issue Jun 7, 2023 · 1 comment

Comments

@enitrat
Copy link
Collaborator

enitrat commented Jun 7, 2023

In this example, we will implement a custom StorageAccess implementation for a struct.
We will demonstrate how we can pack multiple fields together instead of storing them in different storage addresses.

You will optimize storage by packing values together using bitshifts and bitmasks inside the read_at_offset_internal and write_at_offset_internal methods of the StorageAccess trait.

For example,

struct Vote{
   proposal_id: u8,
   timestamp: u32, 
   value: bool,
}
@enitrat enitrat changed the title feat: Custom StorageAccess implementation feat: Custom StorageAccess implementation (packing) Jun 28, 2023
@julio4
Copy link
Member

julio4 commented Aug 7, 2023

Updated in #62

@julio4 julio4 closed this as completed Aug 7, 2023
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

No branches or pull requests

2 participants