diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-08 23:19:53 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-08 23:19:53 +0800 |
commit | 0214cbe0fb01e623a905a6ff8875896f78e00840 (patch) | |
tree | 0b9227ca5be01d6b667dd2651771b08d8f75499d /eth/downloader/peer.go | |
parent | 7c678554b585b70d5498442bc7122e3091ace80f (diff) | |
parent | edad47bf0e68ad02ee0cb6efd776c9f9be67ad8e (diff) | |
download | go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar.gz go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar.bz2 go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar.lz go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar.xz go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.tar.zst go-tangerine-0214cbe0fb01e623a905a6ff8875896f78e00840.zip |
Merge pull request #863 from karalabe/ordered-block-download
eth/downloader: prioritize block fetch based on chain position, cap memo...
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r-- | eth/downloader/peer.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index 91977f592..45ec1cbfd 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -78,7 +78,7 @@ func newPeer(id string, hash common.Hash, getHashes hashFetcherFn, getBlocks blo } // fetch a chunk using the peer -func (p *peer) fetch(chunk *chunk) error { +func (p *peer) fetch(request *fetchRequest) error { p.mu.Lock() defer p.mu.Unlock() @@ -88,13 +88,12 @@ func (p *peer) fetch(chunk *chunk) error { // set working state p.state = workingState - // convert the set to a fetchable slice - hashes, i := make([]common.Hash, chunk.hashes.Size()), 0 - chunk.hashes.Each(func(v interface{}) bool { - hashes[i] = v.(common.Hash) - i++ - return true - }) + + // Convert the hash set to a fetchable slice + hashes := make([]common.Hash, 0, len(request.Hashes)) + for hash, _ := range request.Hashes { + hashes = append(hashes, hash) + } p.getBlocks(hashes) return nil |