4 "github.com/anacrolix/torrent/metainfo"
7 // The public interface for a torrent within a Client.
9 // A handle to a live torrent within a Client.
15 func (t Torrent) InfoHash() InfoHash {
16 return t.torrent.InfoHash
19 // Closed when the info (.Info()) for the torrent has become available. Using
20 // features of Torrent that require the info before it is available will have
21 // undefined behaviour.
22 func (t *Torrent) GotInfo() <-chan struct{} {
23 return t.torrent.gotMetainfo
26 func (t *Torrent) Info() *metainfo.Info {
30 // Returns a Reader bound to the torrent's data. All read calls block until
31 // the data requested is actually available. Priorities are set to ensure the
32 // data requested will be downloaded as soon as possible.
33 func (t *Torrent) NewReader() (ret *Reader) {
36 readahead: 5 * 1024 * 1024,
41 // Returns the state of pieces of the torrent. They are grouped into runs of
42 // same state. The sum of the state run lengths is the number of pieces
44 func (t *Torrent) PieceStateRuns() []PieceStateRun {
46 defer t.stateMu.Unlock()
47 return t.torrent.pieceStateRuns()
50 func (t Torrent) NumPieces() int {
54 func (t Torrent) Drop() {
56 t.cl.dropTorrent(t.torrent.InfoHash)
60 func (t Torrent) BytesCompleted() int64 {
62 defer t.cl.mu.RUnlock()
63 return t.bytesCompleted()