-
Notifications
You must be signed in to change notification settings - Fork 72
memory-db: allow changing the default hasher #224
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
Conversation
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
|
@alexggh you should directly bump the crate version. |
memory-db/src/lib.rs
Outdated
| impl<H, KF, T, S> Default for MemoryDB<H, KF, T, S> | ||
| where | ||
| H: KeyHasher, | ||
| T: for<'a> From<&'a [u8]>, | ||
| KF: KeyFunction<H>, | ||
| S: BuildHasher + Default, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| impl<H, KF, T, S> Default for MemoryDB<H, KF, T, S> | |
| where | |
| H: KeyHasher, | |
| T: for<'a> From<&'a [u8]>, | |
| KF: KeyFunction<H>, | |
| S: BuildHasher + Default, | |
| impl<H, KF, T> Default for MemoryDB<H, KF, T, RandomState> | |
| where | |
| H: KeyHasher, | |
| T: for<'a> From<&'a [u8]>, | |
| KF: KeyFunction<H>, |
This way you can just use default() without declaring the random state. Similar to HashMap we should then provide a function with_random_state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, specialising the default meant that I had to plumb a few places where default() did not work anymore when using it with the custom RandomState.
But, I like that more since it is similar with how hashmap is used.
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Done. |
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
To be used by paritytech/polkadot-sdk#9127, to replace the default hasher with a custom one.