}
func (cs *ConnStats) wroteMsg(msg *pp.Message) {
+ // TODO: Track messages and not just chunks.
switch msg.Type {
case pp.Piece:
cs.ChunksWritten++
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(),
}
// 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)
// Torrent-level statistics.
stats TorrentStats
+ // Count of each request across active connections.
pendingRequests map[request]int
}
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 {