aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-04 00:00:54 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-08 18:23:58 +0800
commitb40c796ff726d54efc8c7933e1586869c2a0985a (patch)
tree435c1cda94d525f7e3a80be599bc02c6003e274d /eth/downloader/downloader.go
parent1d7bf3d39fbd6b1a53913bb309bc07500b220ded (diff)
downloadgo-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar.gz
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar.bz2
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar.lz
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar.xz
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.tar.zst
go-tangerine-b40c796ff726d54efc8c7933e1586869c2a0985a.zip
eth/downloader: preallocate the block cache
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r--eth/downloader/downloader.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index d113aa33f..cd2fd81f1 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -341,12 +341,12 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
active.getHashes(head)
continue
}
- // We're done, allocate the download cache and proceed pulling the blocks
+ // We're done, prepare the download cache and proceed pulling the blocks
offset := 0
if block := d.getBlock(head); block != nil {
offset = int(block.NumberU64() + 1)
}
- d.queue.Alloc(offset)
+ d.queue.Prepare(offset)
finished = true
case blockPack := <-d.blockCh:
@@ -504,7 +504,7 @@ out:
}
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
- request := d.queue.Reserve(peer)
+ request := d.queue.Reserve(peer, peer.Capacity())
if request == nil {
continue
}
@@ -551,7 +551,7 @@ func (d *Downloader) banBlocks(peerId string, head common.Hash) error {
if peer == nil {
return nil
}
- request := d.queue.Reserve(peer)
+ request := d.queue.Reserve(peer, MaxBlockFetch)
if request == nil {
return nil
}