For now always read ahead 4 extra blocks

This commit is contained in:
Matt Joiner 2014-12-01 17:02:31 -06:00
parent fec0ac6ea5
commit 0a91eef496
1 changed files with 7 additions and 5 deletions

View File

@ -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 {