aboutsummaryrefslogtreecommitdiffstats
path: root/core/headerchain.go
diff options
context:
space:
mode:
authorb00ris <b00ris@mail.ru>2019-01-24 19:18:26 +0800
committerFelix Lange <fjl@users.noreply.github.com>2019-01-24 19:18:26 +0800
commit769657060e888612e7d585c6b6eae16a64c4ad19 (patch)
tree12d6b3dad5209d35972d3569b5ff56ad55363b40 /core/headerchain.go
parentb8f9b3779fbdc62d5a935b57f1360608fa4600b4 (diff)
downloadgo-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.gz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.bz2
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.lz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.xz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.zst
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.zip
les: implement ultralight client (#16904)
For more information about this light client mode, read https://hackmd.io/s/HJy7jjZpm
Diffstat (limited to 'core/headerchain.go')
-rw-r--r--core/headerchain.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/headerchain.go b/core/headerchain.go
index d2093113c..8904dd887 100644
--- a/core/headerchain.go
+++ b/core/headerchain.go
@@ -219,14 +219,18 @@ func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int)
// Generate the list of seal verification requests, and start the parallel verifier
seals := make([]bool, len(chain))
- for i := 0; i < len(seals)/checkFreq; i++ {
- index := i*checkFreq + hc.rand.Intn(checkFreq)
- if index >= len(seals) {
- index = len(seals) - 1
+ if checkFreq != 0 {
+ // In case of checkFreq == 0 all seals are left false.
+ for i := 0; i < len(seals)/checkFreq; i++ {
+ 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)
defer close(abort)