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 over StorageDoubleMap with partial keys not working #1251

Closed
5tan-enj opened this issue Nov 10, 2023 · 2 comments · Fixed by #1298
Closed

Iterating over StorageDoubleMap with partial keys not working #1251

5tan-enj opened this issue Nov 10, 2023 · 2 comments · Fixed by #1298
Assignees

Comments

@5tan-enj
Copy link

Problem :
Trying to fetch values from a StorageDoubleMap by supplying only a partial key, the result still returns all values in storage

Example :

Code :

pub async fn calculate_pool_data(pool_id : u32, era: u32) -> Result<(), Box<dyn std::error::Error>> {
	let relay_client = RelayClient::from_url("wss://rpc.relay.blockchain.enjin.io:443").await?;

	// get unbonding members
	let unbonding_members = {
		let query = relay::storage().nomination_pools().unbonding_members_iter1(6u32);
		let mut results = relay_client.storage().at_latest().await?.iter(query).await?;

		let mut unbonding_members = HashMap::new();
		while let Some(Ok((key, prefs))) = results.next().await {
			unbonding_members.insert(key, prefs);
		}
		unbonding_members
	};

	println!("Unbonding members {:?}", unbonding_members.len());

	Ok(())

}

Output :

Unbonding members 109

Expected Output :
1 (there is only one unbonding member)

Screenshot 2023-11-10 at 9 03 51 AM
@jsdw
Copy link
Collaborator

jsdw commented Nov 10, 2023

Thankyou for raising this; that is unexpected! We'll look into it!

lexnv added a commit that referenced this issue Nov 28, 2023
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv
Copy link
Collaborator

lexnv commented Nov 28, 2023

I was able to reproduce this issue on the following branch: https://github.com/paritytech/subxt/compare/lexnv/repro-case-1251?expand=1.

Indeed there seems to be a mismatch, most probably due to constructing the query differently.

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

Successfully merging a pull request may close this issue.

3 participants