torrent.go | 16 ++++++++++++++++ diff --git a/torrent.go b/torrent.go index 19b5f053a7a34b8fcfa71c50bcf5d2243e4a9306..ce9d92730b0e5d52248f79b0dd80fd9eca51bea9 100644 --- a/torrent.go +++ b/torrent.go @@ -561,3 +561,19 @@ } p := t.Pieces[index] return p.EverHashed && len(p.PendingChunkSpecs) != 0 } + +func (t *torrent) connHasWantedPieces(c *connection) bool { + for p := range t.Pieces { + if t.wantPiece(p) && c.PeerHasPiece(pp.Integer(p)) { + return true + } + } + return false +} + +func (t *torrent) extentPieces(off, _len int64) (pieces []int) { + for i := off / int64(t.UsualPieceSize()); i*int64(t.UsualPieceSize()) < off+_len; i++ { + pieces = append(pieces, int(i)) + } + return +}