]> Sergey Matveev's repositories - btrtrc.git/commitdiff
TODOs and comments
authorMatt Joiner <anacrolix@gmail.com>
Sun, 4 Feb 2018 08:14:07 +0000 (19:14 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 4 Feb 2018 08:14:07 +0000 (19:14 +1100)
conn_stats.go
connection.go
peer_protocol/decoder.go
torrent.go

index a54fd7b89917d86b744eec7a6bc27899040f7ee7..144ab0cb682e0c960df4f6f40a506dc49c3540bc 100644 (file)
@@ -36,6 +36,7 @@ type ConnStats struct {
 }
 
 func (cs *ConnStats) wroteMsg(msg *pp.Message) {
+       // TODO: Track messages and not just chunks.
        switch msg.Type {
        case pp.Piece:
                cs.ChunksWritten++
index 7e475659511d8091f8e45a2ad691391e5773bf57..3824fc3d0a1ac8af2fa8143b38f61bb852e79182 100644 (file)
@@ -210,6 +210,7 @@ func (cn *connection) WriteStatus(w io.Writer, t *Torrent) {
                cn.completedString(),
                len(cn.peerTouchedPieces),
                cn.stats.ChunksReadUseful,
+               // TODO: Use ChunksRead? Verify that value is the same as this sum?
                cn.stats.ChunksReadUnwanted+cn.stats.ChunksReadUseful,
                cn.stats.ChunksWritten,
                cn.numLocalRequests(),
index 2d82c1c65988fc3ebd07aad799905c6d34c23a4e..3f66cdc99fba475592dd5e49d712978db6f75657 100644 (file)
@@ -17,6 +17,7 @@ type Decoder struct {
 }
 
 // io.EOF is returned if the source terminates cleanly on a message boundary.
+// TODO: Is that before or after the message?
 func (d *Decoder) Decode(msg *Message) (err error) {
        var length Integer
        err = binary.Read(d.R, binary.BigEndian, &length)
index fca9179899f53fbf73b47bd4e04ee8550ee49e79..a23029bcbac44a78d333cab054a682821826c7a0 100644 (file)
@@ -134,6 +134,7 @@ type Torrent struct {
        // Torrent-level statistics.
        stats TorrentStats
 
+       // Count of each request across active connections.
        pendingRequests map[request]int
 }
 
@@ -848,6 +849,8 @@ func (t *Torrent) worstBadConn() *connection {
                if c.stats.ChunksReadUnwanted >= 6 && c.stats.ChunksReadUnwanted > c.stats.ChunksReadUseful {
                        return c
                }
+               // If the connection is in the worst half of the established
+               // connection quota and is older than a minute.
                if wcs.Len() >= (t.maxEstablishedConns+1)/2 {
                        // Give connections 1 minute to prove themselves.
                        if time.Since(c.completedHandshake) > time.Minute {