Skip to content

Commit 2a79021

Browse files
refactor: use slices.Backward to simplify the code (#893)
Signed-off-by: chuanshanjida <chuanshanjida@outlook.com>
1 parent 617eee0 commit 2a79021

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cmd/ulxly/common/imt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package common
33
import (
44
"encoding/binary"
55
"fmt"
6+
"slices"
67

78
"github.com/0xPolygon/polygon-cli/bindings/ulxly"
89
"github.com/ethereum/go-ethereum/common"
@@ -172,8 +173,8 @@ func Check(roots []common.Hash, leaf common.Hash, position uint32, siblings [32]
172173
}
173174

174175
isProofValid := false
175-
for i := len(roots) - 1; i >= 0; i-- {
176-
if roots[i].Cmp(node) == 0 {
176+
for _, v := range slices.Backward(roots) {
177+
if v.Cmp(node) == 0 {
177178
isProofValid = true
178179
break
179180
}

0 commit comments

Comments
 (0)