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

Iterating StorageDoubleMap #526

Closed
trusch opened this issue May 3, 2022 · 2 comments
Closed

Iterating StorageDoubleMap #526

trusch opened this issue May 3, 2022 · 2 comments
Labels
question Further information is requested

Comments

@trusch
Copy link

trusch commented May 3, 2022

Hello,

I'd like to iterate over parts of the content of a StorageDoubleMap. By now subxt generates me two different functions for accessing a double map: 1) Get one element by specifying the primary and the secondary key and 2) Iterate over all the elements in the map.

What I would actually want to do is to only specify the primary key and then iterate over all the entries that belong to this top level key.

Is there any other way of doing this, or am I missing something obvious?

Thanks in advance!

@lexnv lexnv added the question Further information is requested label May 9, 2022
@lexnv
Copy link
Collaborator

lexnv commented May 11, 2022

Hey,

There is one example of iterating over a double map using raw primitives (paritytech/polkadot-interaction-examples-rs#1).

The main idea behind it would be to manually construct the key:

  • key contains twox_128(Pallet) ++ twox_128(Storage name) ++ hash(key1) ++ key1
  • the key can be fed into state_getKeys request
  • iterate for each of those keys and make a state_getStorage

Will try to provide an example into subxt as well soon.

@jsdw
Copy link
Collaborator

jsdw commented Jun 21, 2022

Have a look at the example in #537: https://github.com/paritytech/subxt/pull/537/files#diff-433d49e107326a73dda6220d4f74a4a59b7f5dc745ae54eff523629424db75ed

Hopefully that PR/example addresses this issue, so I'll close it now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants