mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
eth/protocols/snap: optimize incHash (#32748)
This commit is contained in:
parent
4d6d5a3abf
commit
ed264a1f19
1 changed files with 7 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue