Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Implement the Tendermint Merkle tree (RFC6962) #292

Merged
merged 4 commits into from
Jul 16, 2019
Merged

Conversation

ebuchman
Copy link
Contributor

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] {
Copy link
Contributor

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] {


/// 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();
Copy link
Contributor

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
Copy link
Contributor

I'd say merge this as-is. My comments re: iterators are slightly less trivial to implement than I realized at first

@tarcieri
Copy link
Contributor

I have a giant PR I want to open, so I'll go ahead and merge this first 😉

@tarcieri tarcieri merged commit 04cd14b into master Jul 16, 2019
@tarcieri tarcieri deleted the bucky/merkle branch July 16, 2019 17:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants