download_strategies.go | 5 ++++- diff --git a/download_strategies.go b/download_strategies.go index bc7287594a4ec233ac7833f9342df40db432135a..e0e79814e0d79ef31e9b3bd44262ef83e27fceb6 100644 --- a/download_strategies.go +++ b/download_strategies.go @@ -176,6 +176,9 @@ } // Wrapper around connection.request that tracks request heat. func (me *requestFiller) request(req request) bool { + if me.pieces == nil { + me.pieces = make(map[int]struct{}) + } me.pieces[int(req.Index)] = struct{}{} if me.c.RequestPending(req) { return true @@ -330,7 +333,7 @@ return true } func (me *responsiveDownloadStrategy) FillRequests(t *torrent, c *connection) (pieces []int) { - rf := requestFiller{c, t, me, make(map[int]struct{}, t.NumPieces())} + rf := requestFiller{c: c, t: t, s: me} rf.Run() for p := range rf.pieces { pieces = append(pieces, p)