go cl.verifyPiece(t, pieceIndex)
}
+// Queue a piece check if one isn't already queued, and the piece has never
+// been checked before.
func (cl *Client) queueFirstHash(t *torrent, piece int) {
p := t.Pieces[piece]
if p.EverHashed || p.Hashing || p.QueuedForHash {
c.PeerRequests = make(map[request]struct{}, maxRequests)
}
request := newRequest(msg.Index, msg.Begin, msg.Length)
- // TODO: Requests should be satisfied from a dedicated upload routine.
+ // TODO: Requests should be satisfied from a dedicated upload
+ // routine.
// c.PeerRequests[request] = struct{}{}
p := make([]byte, msg.Length)
n, err := t.Data.ReadAt(p, int64(t.PieceLength(0))*int64(msg.Index)+int64(msg.Begin))
return me.cl.torrentReadAt(me.torrent, off, p)
}
+// Returns nil metainfo if it isn't in the cache.
func (cl *Client) torrentCacheMetaInfo(ih InfoHash) (mi *metainfo.MetaInfo, err error) {
f, err := os.Open(cl.torrentFileCachePath(ih))
if err != nil {
WriteSectionTo(w io.Writer, off, n int64) (written int64, err error)
}
-// Is not aware of Client.
+// Is not aware of Client. Maintains state of torrent for with-in a Client.
type torrent struct {
stateMu sync.Mutex
closing chan struct{}
wantPeers sync.Cond
// BEP 12 Multitracker Metadata Extension. The tracker.Client instances
- // mirror their respective URLs from the announce-list key.
+ // mirror their respective URLs from the announce-list metainfo key.
Trackers [][]tracker.Client
DisplayName string
MetaData []byte