]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Comments
authorMatt Joiner <anacrolix@gmail.com>
Tue, 24 Feb 2015 14:34:57 +0000 (01:34 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 24 Feb 2015 14:34:57 +0000 (01:34 +1100)
client.go
torrent.go

index f3f8a59960cb81a4ca9cb9ad8e084204ae491086..d9c929e3de0352628ce10e4fc7d1f423590d1b4a 100644 (file)
--- a/client.go
+++ b/client.go
@@ -92,6 +92,8 @@ func (cl *Client) queuePieceCheck(t *torrent, pieceIndex pp.Integer) {
        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 {
@@ -1196,7 +1198,8 @@ func (me *Client) connectionLoop(t *torrent, c *connection) error {
                                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))
@@ -1756,6 +1759,7 @@ func (me Torrent) ReadAt(p []byte, off int64) (n int, err error) {
        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 {
index 53cb980c33771c891b4d5b955745719badce9ade..450f15fe35a043290f209009740d793ab71c65b0 100644 (file)
@@ -47,7 +47,7 @@ type torrentData interface {
        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{}
@@ -77,7 +77,7 @@ type torrent 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