forked from cerc-io/plugeth
Merge pull request #996 from karalabe/fix-potential-crosscheck-race
eth/downloader: circumvent download race between crosscheck and hashes
This commit is contained in:
commit
82c0780f81
@ -284,12 +284,14 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
|
|||||||
}
|
}
|
||||||
if !done {
|
if !done {
|
||||||
// Try and fetch a random block to verify the hash batch
|
// Try and fetch a random block to verify the hash batch
|
||||||
cross := inserts[rand.Intn(len(inserts))]
|
// Skip the last hash as the cross check races with the next hash fetch
|
||||||
glog.V(logger.Detail).Infof("Cross checking (%s) with %x", active.id, cross)
|
if len(inserts) > 1 {
|
||||||
|
cross := inserts[rand.Intn(len(inserts)-1)]
|
||||||
d.checks[cross] = time.Now().Add(blockTTL)
|
glog.V(logger.Detail).Infof("Cross checking (%s) with %x", active.id, cross)
|
||||||
active.getBlocks([]common.Hash{cross})
|
|
||||||
|
|
||||||
|
d.checks[cross] = time.Now().Add(blockTTL)
|
||||||
|
active.getBlocks([]common.Hash{cross})
|
||||||
|
}
|
||||||
// Also fetch a fresh
|
// Also fetch a fresh
|
||||||
active.getHashes(head)
|
active.getHashes(head)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user