]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add missing increments to some stats
authorMatt Joiner <anacrolix@gmail.com>
Sat, 3 Feb 2018 00:53:11 +0000 (11:53 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 3 Feb 2018 00:53:11 +0000 (11:53 +1100)
client.go
connection.go
torrent.go

index 3072dcd1a6098b8ad58990a142327ab2425ff95a..bab9e5601cabb925b42983552421a15d29f0a368 100644 (file)
--- 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:
index 73d74604549fd2a9a876d10e316ab9532d941b09..c3a566500bd4d4be1a6433a2c2d411440a8187b9 100644 (file)
@@ -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)
index 99908a92cd0264744ffdb258d7170523e00f451d..a58d6b8f447f97040222279822d96333776fd0f8 100644 (file)
@@ -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++