This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Implement the Tendermint Merkle tree (RFC6962) #292
Merged
Merged
Conversation
This file contains 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
tarcieri
reviewed
Jul 16, 2019
tarcieri
reviewed
Jul 16, 2019
pub const HASH_SIZE: usize = 32; | ||
|
||
/// Compute a simple Merkle root from the arbitrary sized byte slices | ||
pub fn simple_hash_from_byte_slices(byte_slices: &[&[u8]]) -> [u8; HASH_SIZE] { |
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.
This might be an interesting place to use an iterator bound, e.g.:
pub fn compute_simple_hash<'a, T>(byte_slices: T) -> [u8; HASH_SIZE]
where
T: IntoIterator<Item = &'a [u8]>
{
or with the fancy new impl Trait
syntax:
pub fn compute_simple_hash<'a>(byte_slices: impl IntoIterator<Item = &'a [u8]>) ) -> [u8; HASH_SIZE] {
tarcieri
reviewed
Jul 16, 2019
|
||
/// Compute a simple Merkle root from the arbitrary sized byte slices | ||
pub fn simple_hash_from_byte_slices(byte_slices: &[&[u8]]) -> [u8; HASH_SIZE] { | ||
let length = byte_slices.len(); |
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.
Now I notice it'd need to be an ExactSizeIterator heh, so slightly less trivial...
tarcieri
approved these changes
Jul 16, 2019
I'd say merge this as-is. My comments re: iterators are slightly less trivial to implement than I realized at first |
I have a giant PR I want to open, so I'll go ahead and merge this first 😉 |
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
More or less copied from https://github.com/tendermint/tendermint/blob/master/crypto/merkle/simple_tree.go#L9