mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-23 03:51:09 +00:00
eth/protocols/snap: adapt to uint256 API changes (#22851)
This commit is contained in:
parent
c0e201b690
commit
e536bb52ff
@ -42,15 +42,15 @@ func newHashRange(start common.Hash, num uint64) *hashRange {
|
||||
step256.SetFromBig(step)
|
||||
|
||||
return &hashRange{
|
||||
current: uint256.NewInt().SetBytes32(start[:]),
|
||||
current: new(uint256.Int).SetBytes32(start[:]),
|
||||
step: step256,
|
||||
}
|
||||
}
|
||||
|
||||
// Next pushes the hash range to the next interval.
|
||||
func (r *hashRange) Next() bool {
|
||||
next := new(uint256.Int)
|
||||
if overflow := next.AddOverflow(r.current, r.step); overflow {
|
||||
next, overflow := new(uint256.Int).AddOverflow(r.current, r.step)
|
||||
if overflow {
|
||||
return false
|
||||
}
|
||||
r.current = next
|
||||
@ -65,16 +65,17 @@ func (r *hashRange) Start() common.Hash {
|
||||
// End returns the last hash in the current interval.
|
||||
func (r *hashRange) End() common.Hash {
|
||||
// If the end overflows (non divisible range), return a shorter interval
|
||||
next := new(uint256.Int)
|
||||
if overflow := next.AddOverflow(r.current, r.step); overflow {
|
||||
next, overflow := new(uint256.Int).AddOverflow(r.current, r.step)
|
||||
if overflow {
|
||||
return common.HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
}
|
||||
return new(uint256.Int).Sub(next, uint256.NewInt().SetOne()).Bytes32()
|
||||
return next.SubUint64(next, 1).Bytes32()
|
||||
}
|
||||
|
||||
// incHash returns the next hash, in lexicographical order (a.k.a plus one)
|
||||
func incHash(h common.Hash) common.Hash {
|
||||
a := uint256.NewInt().SetBytes32(h[:])
|
||||
a.Add(a, uint256.NewInt().SetOne())
|
||||
var a uint256.Int
|
||||
a.SetBytes32(h[:])
|
||||
a.AddUint64(&a, 1)
|
||||
return common.Hash(a.Bytes32())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user