mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
engine_v2: fix negative underflow in getBlockInfoByEpochNum (#1481)
This commit is contained in:
parent
b8e5baa978
commit
5a6d25ec08
1 changed files with 7 additions and 1 deletions
|
|
@ -271,7 +271,13 @@ func (x *XDPoS_v2) binarySearchBlockByEpochNumber(chain consensus.ChainReader, t
|
||||||
} else {
|
} else {
|
||||||
end = header.Number.Uint64()
|
end = header.Number.Uint64()
|
||||||
// trick to shorten the search
|
// trick to shorten the search
|
||||||
estStart := end - uint64(round)%x.config.Epoch
|
estStart := uint64(0)
|
||||||
|
// if statement to avoid negative underflow
|
||||||
|
roundModEpoch := uint64(round) % x.config.Epoch
|
||||||
|
if end >= roundModEpoch {
|
||||||
|
estStart = end - roundModEpoch
|
||||||
|
}
|
||||||
|
|
||||||
if start < estStart {
|
if start < estStart {
|
||||||
start = estStart
|
start = estStart
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue