Skip to content

Commit

Permalink
Remove leaf hashing in MerkleRoot function
Browse files Browse the repository at this point in the history
See ethereum/consensus-specs#646 for clarification.
  • Loading branch information
wemeetagain committed Feb 19, 2019
1 parent c30bef0 commit fcf3168
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 0 additions & 6 deletions shared/hashutil/merkleRoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ package hashutil
func MerkleRoot(values [][]byte) []byte {
length := len(values)

// Data is hashed so as to be stored as leaves in the tree.
for i, v := range values {
hashedValue := Hash(v)
values[i] = hashedValue[:]
}

newSet := make([][]byte, length, length*2)
newSet = append(newSet, values...)

Expand Down
8 changes: 4 additions & 4 deletions shared/hashutil/merkleRoot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func TestMerkleRoot(t *testing.T) {
{'d'},
}

hashedV1 := Hash([]byte{'a'})
hashedV2 := Hash([]byte{'b'})
hashedV3 := Hash([]byte{'c'})
hashedV4 := Hash([]byte{'d'})
hashedV1 := []byte{'a'}
hashedV2 := []byte{'b'}
hashedV3 := []byte{'c'}
hashedV4 := []byte{'d'}

leftNode := Hash(append(hashedV1[:], hashedV2[:]...))
rightNode := Hash(append(hashedV3[:], hashedV4[:]...))
Expand Down

0 comments on commit fcf3168

Please sign in to comment.