diff --git a/conn_stats.go b/conn_stats.go index a54fd7b8..144ab0cb 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -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++ diff --git a/connection.go b/connection.go index 7e475659..3824fc3d 100644 --- a/connection.go +++ b/connection.go @@ -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(), diff --git a/peer_protocol/decoder.go b/peer_protocol/decoder.go index 2d82c1c6..3f66cdc9 100644 --- a/peer_protocol/decoder.go +++ b/peer_protocol/decoder.go @@ -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) diff --git a/torrent.go b/torrent.go index fca91798..a23029bc 100644 --- a/torrent.go +++ b/torrent.go @@ -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 {