From: Matt Joiner Date: Sat, 3 Feb 2018 00:53:11 +0000 (+1100) Subject: Add missing increments to some stats X-Git-Tag: v1.0.0~221 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=9567aa901c2f5e9f3fc2dc3237645fe0b2d6a5a2;p=btrtrc.git Add missing increments to some stats --- diff --git a/client.go b/client.go index 3072dcd1..bab9e560 100644 --- a/client.go +++ b/client.go @@ -948,6 +948,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *connect } t.saveMetadataPiece(piece, payload[begin:]) c.stats.ChunksReadUseful++ + c.t.stats.ChunksReadUseful++ c.lastUsefulChunkReceived = time.Now() return t.maybeCompleteMetadata() case pp.RequestMetadataExtensionMsgType: diff --git a/connection.go b/connection.go index 73d74604..c3a56650 100644 --- a/connection.go +++ b/connection.go @@ -1080,6 +1080,7 @@ func (c *connection) receiveChunk(msg *pp.Message) { if !t.wantPiece(req) { unwantedChunksReceived.Add(1) c.stats.ChunksReadUnwanted++ + c.t.stats.ChunksReadUnwanted++ return } @@ -1087,6 +1088,9 @@ func (c *connection) receiveChunk(msg *pp.Message) { piece := &t.pieces[index] c.stats.ChunksReadUseful++ + c.t.stats.ChunksReadUseful++ + c.stats.BytesReadUsefulData += int64(len(msg.Piece)) + c.t.stats.BytesReadUsefulData += int64(len(msg.Piece)) c.lastUsefulChunkReceived = time.Now() // if t.fastestConn != c { // log.Printf("setting fastest connection %p", c) diff --git a/torrent.go b/torrent.go index 99908a92..a58d6b8f 100644 --- a/torrent.go +++ b/torrent.go @@ -1514,6 +1514,9 @@ func (t *Torrent) pieceHashed(piece int, correct bool) { } p.everHashed = true if correct { + if len(touchers) != 0 { + t.stats.PiecesDirtiedGood++ + } for _, c := range touchers { c.stats.PiecesDirtiedGood++ } @@ -1523,6 +1526,7 @@ func (t *Torrent) pieceHashed(piece int, correct bool) { } } else { if len(touchers) != 0 { + t.stats.PiecesDirtiedBad++ for _, c := range touchers { // Y u do dis peer?! c.stats.PiecesDirtiedBad++