Skip to content

Commit e536bb5

Browse files
authored
eth/protocols/snap: adapt to uint256 API changes (#22851)
1 parent c0e201b commit e536bb5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

eth/protocols/snap/range.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ func newHashRange(start common.Hash, num uint64) *hashRange {
4242
step256.SetFromBig(step)
4343

4444
return &hashRange{
45-
current: uint256.NewInt().SetBytes32(start[:]),
45+
current: new(uint256.Int).SetBytes32(start[:]),
4646
step: step256,
4747
}
4848
}
4949

5050
// Next pushes the hash range to the next interval.
5151
func (r *hashRange) Next() bool {
52-
next := new(uint256.Int)
53-
if overflow := next.AddOverflow(r.current, r.step); overflow {
52+
next, overflow := new(uint256.Int).AddOverflow(r.current, r.step)
53+
if overflow {
5454
return false
5555
}
5656
r.current = next
@@ -65,16 +65,17 @@ func (r *hashRange) Start() common.Hash {
6565
// End returns the last hash in the current interval.
6666
func (r *hashRange) End() common.Hash {
6767
// If the end overflows (non divisible range), return a shorter interval
68-
next := new(uint256.Int)
69-
if overflow := next.AddOverflow(r.current, r.step); overflow {
68+
next, overflow := new(uint256.Int).AddOverflow(r.current, r.step)
69+
if overflow {
7070
return common.HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
7171
}
72-
return new(uint256.Int).Sub(next, uint256.NewInt().SetOne()).Bytes32()
72+
return next.SubUint64(next, 1).Bytes32()
7373
}
7474

7575
// incHash returns the next hash, in lexicographical order (a.k.a plus one)
7676
func incHash(h common.Hash) common.Hash {
77-
a := uint256.NewInt().SetBytes32(h[:])
78-
a.Add(a, uint256.NewInt().SetOne())
77+
var a uint256.Int
78+
a.SetBytes32(h[:])
79+
a.AddUint64(&a, 1)
7980
return common.Hash(a.Bytes32())
8081
}

0 commit comments

Comments
 (0)