-
Notifications
You must be signed in to change notification settings - Fork 431
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
Fallible storage get
and set
methods for Lazy
and Mapping
#1910
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
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and clean to me=)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
ced6ba3
to
a2c991b
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
Adds
try_*
methods for reading and writingLazy
andMapping
values to and from storage (forMapping
, the encoded size of the key is also accounted for).Fallible writes are implemented by extending the
Storable
trait withencoded_size
method (which provides a default implementation using the SCALE version method ofencoded_size
). There is alsosize_hint
in 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_size
method to return a constant instead if possible and required.Fallible reads are implemented using the
contains_storage_key
API, 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 correspondingReturnCode
to the contracts pallet, which can then be used by theget_storage
API method. But for now, the two subsequent calls are necessary.