TODOs and comments

This commit is contained in:
Matt Joiner 2018-02-04 19:14:07 +11:00
parent e0c2265cb0
commit 44e44637bf
4 changed files with 6 additions and 0 deletions

View 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++

View 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(),

View 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)

View 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 {