reader.go | 7 +++---- diff --git a/reader.go b/reader.go index a5ea62f2ce092535b4fdf19a95a24f0a93696a8c..648228be423fa2417e81bb9e36db4b02f0aca52e 100644 --- a/reader.go +++ b/reader.go @@ -8,7 +8,6 @@ "log" "sync" "github.com/anacrolix/missinggo" - "github.com/anacrolix/torrent/peer_protocol" ) type Reader interface { @@ -213,8 +212,8 @@ err = *ctxErr return } } - pi := peer_protocol.Integer(r.torrentOffset(pos) / r.t.info.PieceLength) - ip := r.t.info.Piece(int(pi)) + pi := pieceIndex(r.torrentOffset(pos) / r.t.info.PieceLength) + ip := r.t.info.Piece(pi) po := r.torrentOffset(pos) % r.t.info.PieceLength b1 := missinggo.LimitLen(b, ip.Length()-po, avail) n, err = r.t.readAt(b1, r.torrentOffset(pos)) @@ -225,7 +224,7 @@ } r.t.cl.lock() // TODO: Just reset pieces in the readahead window. This might help // prevent thrashing with small caches and file and piece priorities. - log.Printf("error reading torrent %s piece %d offset %d, %d bytes: %s", + log.Printf("error reading torrent %s piece %d offset %d, %d bytes: %v", r.t.infoHash.HexString(), pi, po, len(b1), err) r.t.updateAllPieceCompletions() r.t.updateAllPiecePriorities()