}
if torrent.haveInfo() {
torrent.initRequestOrdering(conn)
+ me.replenishConnRequests(torrent, conn)
}
err = me.connectionLoop(torrent, conn)
if err != nil {
conn.pieceRequestOrder.DeletePiece(int(piece))
}
if t.wantPiece(int(piece)) && conn.PeerHasPiece(piece) {
- conn.pendPiece(int(piece), t.Pieces[piece].Priority)
+ t.connPendPiece(conn, int(piece))
+ me.replenishConnRequests(t, conn)
}
}
if t.haveAllPieces() && me.noUpload {
)
func (t *torrent) PieceNumPendingBytes(index pp.Integer) (count pp.Integer) {
+ piece := t.Pieces[index]
+ if !piece.EverHashed {
+ return t.PieceLength(index)
+ }
pendingChunks := t.Pieces[index].PendingChunkSpecs
count = pp.Integer(len(pendingChunks)) * chunkSize
_lastChunkSpec := lastChunkSpec(t.PieceLength(index))