Substrate: double map key2 hasher metadata

Created on 2 May 2019  ·  3Comments  ·  Source: paritytech/substrate

Make use of metadata::StorageHasher to represent second key hasher of double map storage.

Also the code of double map storage in srml-support-procedural should make use of HasherKind

D2-breaksapi I6-refactor 🧹 I7-optimisation ⏱ Q2-easy

Most helpful comment

The PR seems good but there should be changed in srml/support/procedural/src/storage/impls.rs I think, I expect your error comes from there.

In the previous version I used Hashable trait to hash key in the implementation of double map but now you can use the struct (up to what is most straightforward in the implementation.

Your error comes from this line I think https://github.com/paritytech/substrate/blob/master/srml/support/procedural/src/storage/impls.rs#L631

Also to ease debugging of procedural macro you can expand the result using this command cargo +nightly rustc --profile=check --package name_of_your_package --lib -- -Zunstable-options --pretty=expanded

All 3 comments

I can mentor

@thiolliere I'm trying to fix it in this WIP PR.
But the test of srml-support is failed with reason:

error[E0599]: no associated item named `Blake2_256` found for type `dyn sr_api_hidden_includes_decl_storage::hidden
_include::Hashable` in the current scope
   --> srml/system/src/lib.rs:312:1
    |
312 | / decl_storage! {
313 | |     trait Store for Module<T: Trait> as System {
314 | |         /// Extrinsics nonce for accounts.
315 | |         pub AccountNonce get(account_nonce): map T::AccountId => T::Index;
...   |
375 | |     }
376 | | }
    | | ^
    | | |
    | |_associated item not found in `dyn sr_api_hidden_includes_decl_storage::hidden_include::Hashable`
    |   help: did you mean: `blake2_256`

It would be great if you can point a direction for me.

The PR seems good but there should be changed in srml/support/procedural/src/storage/impls.rs I think, I expect your error comes from there.

In the previous version I used Hashable trait to hash key in the implementation of double map but now you can use the struct (up to what is most straightforward in the implementation.

Your error comes from this line I think https://github.com/paritytech/substrate/blob/master/srml/support/procedural/src/storage/impls.rs#L631

Also to ease debugging of procedural macro you can expand the result using this command cargo +nightly rustc --profile=check --package name_of_your_package --lib -- -Zunstable-options --pretty=expanded

Was this page helpful?
0 / 5 - 0 ratings