Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add iteration with key information when using $hash_concat #5238

Closed
wants to merge 1 commit into from

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Mar 12, 2020

Fix #4362

When iterating on a storage_map which use twox_64_concat we must be able to get the key alongside the value. This PR create a new function on StoragePrefixedMap to make it possible.

In future PR:

DoubleMap::iter_prefix (which iter on all the second key associated to one first key) can't iterate with key information yet. I will do in a following PR

Additionnal notes

The fact the the iteration stop immediately if a value fail to decode was made to follow the same behavior of StoragPrefixedMap::iter(). Though maybe we should move both implementation to just ignore failed to decode value.

Alternative implementation

If having () instead of key when the hasher doesn't give information is too confusing we could also go in another direction by making such function available with a where statement.

Though to do so I would actually prefer merging StorageMap and generator::StorageMap and having the function iter_with_info()... where Hasher: HasherWithInfo.

@gui1117 gui1117 requested a review from kianenigma as a code owner March 12, 2020 16:37
@gui1117 gui1117 added A0-please_review Pull request needs code review. B1-apinoteworthy and removed B2-breaksapi labels Mar 12, 2020
@gavofyork
Copy link
Member

gavofyork commented Mar 12, 2020

This is already implemented in my PR #5226; please don't merge as-is as it'll just create a bunch of needless conflicts.

@gui1117 gui1117 added A1-onice and removed A0-please_review Pull request needs code review. labels Mar 13, 2020
@gui1117
Copy link
Contributor Author

gui1117 commented Mar 23, 2020

partially implemented in #5226
and superseeded by #5335

@gui1117 gui1117 closed this Mar 23, 2020
@gui1117 gui1117 deleted the gui-key-info-iteration branch September 23, 2021 11:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

decl_storage: storage the key alongside the value to be able to iterate on key/value
3 participants