mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 01:40:44 +00:00
core: fix integer divide by zero in function ValidateHeaderChain
This commit is contained in:
parent
7c9df61bd9
commit
cc5359e063
1 changed files with 10 additions and 6 deletions
|
|
@ -233,14 +233,18 @@ func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int)
|
||||||
|
|
||||||
// Generate the list of seal verification requests, and start the parallel verifier
|
// Generate the list of seal verification requests, and start the parallel verifier
|
||||||
seals := make([]bool, len(chain))
|
seals := make([]bool, len(chain))
|
||||||
for i := 0; i < len(seals)/checkFreq; i++ {
|
if checkFreq != 0 {
|
||||||
index := i*checkFreq + hc.rand.Intn(checkFreq)
|
// In case of checkFreq == 0 all seals are left false.
|
||||||
if index >= len(seals) {
|
for i := 0; i < len(seals)/checkFreq; i++ {
|
||||||
index = len(seals) - 1
|
index := i*checkFreq + hc.rand.Intn(checkFreq)
|
||||||
|
if index >= len(seals) {
|
||||||
|
index = len(seals) - 1
|
||||||
|
}
|
||||||
|
seals[index] = true
|
||||||
}
|
}
|
||||||
seals[index] = true
|
// Last should always be verified to avoid junk
|
||||||
|
seals[len(seals)-1] = true
|
||||||
}
|
}
|
||||||
seals[len(seals)-1] = true // Last should always be verified to avoid junk
|
|
||||||
|
|
||||||
abort, results := hc.engine.VerifyHeaders(hc, chain, seals)
|
abort, results := hc.engine.VerifyHeaders(hc, chain, seals)
|
||||||
defer close(abort)
|
defer close(abort)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue