client.go | 4 +++- torrent.go | 4 ++++ diff --git a/client.go b/client.go index aeff48c0b8a0eb257edeeb1490a186feb5facdb8..602f99c7bd983f873d8146935fea44109a6848fd 100644 --- a/client.go +++ b/client.go @@ -941,6 +941,7 @@ }) } if torrent.haveInfo() { torrent.initRequestOrdering(conn) + me.replenishConnRequests(torrent, conn) } err = me.connectionLoop(torrent, conn) if err != nil { @@ -2139,7 +2140,8 @@ } 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 { diff --git a/torrent.go b/torrent.go index 891e0060b6c93ee3d21adc48fbfdb84183607d33..469d2b15f11ed9fd3e5d165a90573a45a8112d82 100644 --- a/torrent.go +++ b/torrent.go @@ -21,6 +21,10 @@ "github.com/anacrolix/libtorgo/metainfo" ) 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))