Skip to content

Commit

Permalink
refactor: popIfNonEmpty for leaf hashes (#257)
Browse files Browse the repository at this point in the history
Use `popIfNonEmpty` instead of manual advancement of slice.
  • Loading branch information
walldiss authored May 24, 2024
1 parent 7831a96 commit 9fb3c91
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,8 @@ func (proof Proof) VerifyLeafHashes(nth *NmtHasher, verifyCompleteness bool, nID
// if the leaf index falls within the proof range, pop and return a
// leaf
if proof.Start() <= start && start < proof.End() {
leafHash := leafHashes[0]
// advance leafHashes
leafHashes = leafHashes[1:]
return leafHash, nil
return popIfNonEmpty(&leafHashes), nil
}

// if the leaf index is outside the proof range, pop and return a
Expand Down

0 comments on commit 9fb3c91

Please sign in to comment.