mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-26 00:16:18 +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 {
|
||||
end = header.Number.Uint64()
|
||||
// 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 {
|
||||
start = estStart
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue