From 0a91eef4965bda915912857f30c5f3028afb4321 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 1 Dec 2014 17:02:31 -0600 Subject: [PATCH] For now always read ahead 4 extra blocks --- client.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index d6e03cfd..a3ebdad7 100644 --- a/client.go +++ b/client.go @@ -107,11 +107,13 @@ func (me *Client) PrioritizeDataRegion(ih InfoHash, off, len_ int64) error { if !t.haveInfo() { return errors.New("missing metadata") } - i := int(off / int64(t.UsualPieceSize())) - me.queueFirstHash(t, i) - i++ - if i < t.NumPieces() { - me.queueFirstHash(t, i) + firstIndex := int(off / int64(t.UsualPieceSize())) + for i := 0; i < 5; i++ { + index := firstIndex + i + if index >= t.NumPieces() { + continue + } + me.queueFirstHash(t, index) } me.downloadStrategy.TorrentPrioritize(t, off, len_) for _, cn := range t.Conns { -- 2.48.1