Fallible storage get and set methods for Lazy and Mapping#1910
Merged
xermicus merged 25 commits intouse-ink:masterfrom Oct 27, 2023
Merged
Fallible storage get and set methods for Lazy and Mapping#1910xermicus merged 25 commits intouse-ink:masterfrom
get and set methods for Lazy and Mapping#1910xermicus merged 25 commits intouse-ink:masterfrom
Conversation
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
get and set methods for Lazy get and set methods for Lazy and Mapping
5 tasks
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
xgreenx
reviewed
Oct 3, 2023
Contributor
xgreenx
left a comment
There was a problem hiding this comment.
Looks good and clean to me=)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
ced6ba3 to
a2c991b
Compare
xgreenx
approved these changes
Oct 25, 2023
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑These are the results when building the
Link to the run | Last update: Fri Oct 27 13:13:23 CEST 2023 |
ascjones
reviewed
Oct 25, 2023
Collaborator
ascjones
left a comment
There was a problem hiding this comment.
Looks good! I'd like to see the try_ methods exercised in the mapping-integration-tests e2e tests though.
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
ascjones
approved these changes
Oct 27, 2023
Collaborator
ascjones
left a comment
There was a problem hiding this comment.
LGTM! (needs merge conflict fixing)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
try_*methods for reading and writingLazyandMappingvalues to and from storage (forMapping, the encoded size of the key is also accounted for).Fallible writes are implemented by extending the
Storabletrait withencoded_sizemethod (which provides a default implementation using the SCALE version method ofencoded_size). There is alsosize_hintin SCALE but I think we want an exact number and not an estimate. This will encode the stored value twice (the first time it's thrown away; no allocation happening), however users can optimize it by overwriting theencoded_sizemethod to return a constant instead if possible and required.Fallible reads are implemented using the
contains_storage_keyAPI, which will tell the size. This implies two calls to the contracts pallet (one to get the size and one to read the value). This can be improved by adding a correspondingReturnCodeto the contracts pallet, which can then be used by theget_storageAPI method. But for now, the two subsequent calls are necessary.