Skip to content

Commit 9fb3c91

Browse files
authored
refactor: popIfNonEmpty for leaf hashes (#257)
Use `popIfNonEmpty` instead of manual advancement of slice.
1 parent 7831a96 commit 9fb3c91

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

proof.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,8 @@ func (proof Proof) VerifyLeafHashes(nth *NmtHasher, verifyCompleteness bool, nID
344344
// if the leaf index falls within the proof range, pop and return a
345345
// leaf
346346
if proof.Start() <= start && start < proof.End() {
347-
leafHash := leafHashes[0]
348347
// advance leafHashes
349-
leafHashes = leafHashes[1:]
350-
return leafHash, nil
348+
return popIfNonEmpty(&leafHashes), nil
351349
}
352350

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

0 commit comments

Comments
 (0)