From 9fb3c91bf9ded541c4a81ef1f0a0b3cb4e1b113c Mon Sep 17 00:00:00 2001 From: Vlad <13818348+walldiss@users.noreply.github.com> Date: Sat, 25 May 2024 00:58:42 +0300 Subject: [PATCH] refactor: popIfNonEmpty for leaf hashes (#257) Use `popIfNonEmpty` instead of manual advancement of slice. --- proof.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/proof.go b/proof.go index 998b9a8..6e824e5 100644 --- a/proof.go +++ b/proof.go @@ -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