mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
8969b9c58f
shanghai changes to txpool. intrinsic gas updated to match the new version in Erigon. unsure if the `isShanghai` check is robust enough or there would be a better way to approach this.
18 lines
339 B
Go
18 lines
339 B
Go
package math
|
|
|
|
import (
|
|
"math/bits"
|
|
)
|
|
|
|
// SafeMul returns x*y and checks for overflow.
|
|
func SafeMul(x, y uint64) (uint64, bool) {
|
|
hi, lo := bits.Mul64(x, y)
|
|
return lo, hi != 0
|
|
}
|
|
|
|
// SafeAdd returns x+y and checks for overflow.
|
|
func SafeAdd(x, y uint64) (uint64, bool) {
|
|
sum, carryOut := bits.Add64(x, y, 0)
|
|
return sum, carryOut != 0
|
|
}
|