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

Configurable storage hasher #5040

Closed
xlc opened this issue Feb 25, 2020 · 1 comment · Fixed by #6877
Closed

Configurable storage hasher #5040

xlc opened this issue Feb 25, 2020 · 1 comment · Fixed by #6877
Labels
J0-enhancement An additional feature request.
Milestone

Comments

@xlc
Copy link
Contributor

xlc commented Feb 25, 2020

I am updating the storage hasher for our ORML open-web3-stack/open-runtime-module-library#101

For the oracle module, I am using twox64_concat for T::OracleKey, which is an enum for Acala and LamianrChain, so it is safe as there will be only < 10 possible values.

However this may cause issue if someone is using u128 as T::OracleKey.

Without the ability to configure hasher, it is not possible to implement efficient and reusable pallet.

@xlc xlc changed the title Configurable hasher Configurable storage hasher Feb 25, 2020
@gui1117
Copy link
Contributor

gui1117 commented Feb 26, 2020

to make hasher configurable in the current macro we could change decl_storage to get a type instead of one of the defined variant as such:

decl_storage! {
	trait Store for Module<T: Trait> as System {
		Account: map hasher(MyHasher) T::AccountId => ();
	}
}

MyHasher will then have to implement StorageHasher
and also we have to add a metadata function (probably in StorageHasher trait) to retrieve metadata at runtime.

@bkchr bkchr added the J0-enhancement An additional feature request. label Feb 26, 2020
@bkchr bkchr added this to the Ideas milestone Feb 26, 2020
@ghost ghost closed this as completed in #6877 Dec 24, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants