From 98400ab9c7f41194f763e41c7e1bbb1fb5099614 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 2 Dec 2014 18:43:05 -0600 Subject: [PATCH] Harmless shortcut initing peer pieces when we have the torrent info --- client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index cddb442f..7b3a8967 100644 --- a/client.go +++ b/client.go @@ -920,8 +920,14 @@ func (t *torrent) initRequestOrdering(c *connection) { } func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) { - for piece >= len(c.PeerPieces) { - c.PeerPieces = append(c.PeerPieces, false) + if t.haveInfo() { + if c.PeerPieces == nil { + c.PeerPieces = make([]bool, t.NumPieces()) + } + } else { + for piece >= len(c.PeerPieces) { + c.PeerPieces = append(c.PeerPieces, false) + } } c.PeerPieces[piece] = true if t.wantPiece(piece) { -- 2.48.1