Skip to content

Commit

Permalink
Improve mutability testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Bezobchuk committed Sep 1, 2018
1 parent 71265b0 commit bfbcfd1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ func (mt MerkleTree) findLeaf(block Block) (int, error) {
j := len(mt.nodes) - len(mt.blocks) // contains possible leaf index range

// attempt to find the leaf corresponding to the block
for i < len(mt.blocks) && j < len(mt.nodes) && leaf == nil {
for i < len(mt.blocks) {
if bytes.Equal(mt.blocks[i].Bytes(), block.Bytes()) {
leaf = mt.nodes[j]
leafIdx = j

break
}

i++
Expand Down Expand Up @@ -282,8 +284,6 @@ func hashNode(data []byte, internal bool) Node {

if internal {
raw[0] = byte(internalNodePrefix)
} else {
raw[0] = byte(leafNodePrefix)
}

copy(raw[1:], data)
Expand Down

0 comments on commit bfbcfd1

Please sign in to comment.