From ed264a1f198ea4172b4f2fe622bae5987f114561 Mon Sep 17 00:00:00 2001 From: cui Date: Fri, 10 Oct 2025 13:48:25 +0800 Subject: [PATCH] eth/protocols/snap: optimize incHash (#32748) --- eth/protocols/snap/range.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eth/protocols/snap/range.go b/eth/protocols/snap/range.go index 8c98c71d50..f32cca8d23 100644 --- a/eth/protocols/snap/range.go +++ b/eth/protocols/snap/range.go @@ -74,8 +74,11 @@ func (r *hashRange) End() common.Hash { // incHash returns the next hash, in lexicographical order (a.k.a plus one) func incHash(h common.Hash) common.Hash { - var a uint256.Int - a.SetBytes32(h[:]) - a.AddUint64(&a, 1) - return common.Hash(a.Bytes32()) + for i := len(h) - 1; i >= 0; i-- { + h[i]++ + if h[i] != 0 { + break + } + } + return h }