-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
) Add `try_*` methods for reading and writing Lazy and Mapping values to and from storage. For `Mapping`, the encoded size of the key is also accounted for. Fallible writes are implemented by extending the `Storable` trait with `encoded_size` method (which provides a default implementation using the SCALE version method of `encoded_size`). There is also `size_hint` in SCALE but we want an exact number and not an estimate. This will encode the stored value twice (the first time it's thrown away), however users can optimize it by overwriting the `encoded_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). If required, this can be improved by adding a corresponding `ReturnCode` to the contracts pallet, which can then be used by the `get_storage` API method.
- Loading branch information
Showing
9 changed files
with
504 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.