memory-db: allow changing the default hasher#224
Merged
Conversation
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
skunert
approved these changes
Jul 8, 2025
bkchr
approved these changes
Jul 8, 2025
Member
|
@alexggh you should directly bump the crate version. |
bkchr
reviewed
Jul 8, 2025
memory-db/src/lib.rs
Outdated
Comment on lines
245
to
250
| 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, |
Member
There was a problem hiding this comment.
Suggested change
| 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
Contributor
Author
There was a problem hiding this comment.
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.
lexnv
approved these changes
Jul 8, 2025
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Contributor
Author
Done. |
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
alexggh
added a commit
that referenced
this pull request
Jul 11, 2025
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
alexggh
added a commit
that referenced
this pull request
Jul 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To be used by paritytech/polkadot-sdk#9127, to replace the default hasher with a custom one.