mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
pick_more_peer_fetch_header_and_body
This commit is contained in:
parent
472c23a801
commit
eccab312cc
1 changed files with 9 additions and 6 deletions
|
|
@ -369,13 +369,15 @@ func (f *Fetcher) loop() {
|
|||
for hash, announces := range f.announced {
|
||||
if time.Since(announces[0].time) > arriveTimeout-gatherSlack {
|
||||
// Pick a random peer to retrieve from, reset all others
|
||||
announce := announces[rand.Intn(len(announces))]
|
||||
f.forgetHash(hash)
|
||||
|
||||
// If the block still didn't arrive, queue for fetching
|
||||
if f.getBlock(hash) == nil {
|
||||
request[announce.origin] = append(request[announce.origin], hash)
|
||||
f.fetching[hash] = announce
|
||||
// Pick more peers to retrieve from
|
||||
for _, announce := range announces {
|
||||
request[announce.origin] = append(request[announce.origin], hash)
|
||||
}
|
||||
f.fetching[hash] = announces[rand.Intn(len(announces))]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -404,13 +406,14 @@ func (f *Fetcher) loop() {
|
|||
|
||||
for hash, announces := range f.fetched {
|
||||
// Pick a random peer to retrieve from, reset all others
|
||||
announce := announces[rand.Intn(len(announces))]
|
||||
f.forgetHash(hash)
|
||||
|
||||
// If the block still didn't arrive, queue for completion
|
||||
if f.getBlock(hash) == nil {
|
||||
request[announce.origin] = append(request[announce.origin], hash)
|
||||
f.completing[hash] = announce
|
||||
for _, announce := range announces {
|
||||
request[announce.origin] = append(request[announce.origin], hash)
|
||||
}
|
||||
f.completing[hash] = announces[rand.Intn(len(announces))]
|
||||
}
|
||||
}
|
||||
// Send out all block body requests
|
||||
|
|
|
|||
Loading…
Reference in a new issue