Add missing increments to some stats

This commit is contained in:
Matt Joiner 2018-02-03 11:53:11 +11:00
parent 5a4e8cd4c5
commit 9567aa901c
3 changed files with 9 additions and 0 deletions

View File

@ -948,6 +948,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *connect
} }
t.saveMetadataPiece(piece, payload[begin:]) t.saveMetadataPiece(piece, payload[begin:])
c.stats.ChunksReadUseful++ c.stats.ChunksReadUseful++
c.t.stats.ChunksReadUseful++
c.lastUsefulChunkReceived = time.Now() c.lastUsefulChunkReceived = time.Now()
return t.maybeCompleteMetadata() return t.maybeCompleteMetadata()
case pp.RequestMetadataExtensionMsgType: case pp.RequestMetadataExtensionMsgType:

View File

@ -1080,6 +1080,7 @@ func (c *connection) receiveChunk(msg *pp.Message) {
if !t.wantPiece(req) { if !t.wantPiece(req) {
unwantedChunksReceived.Add(1) unwantedChunksReceived.Add(1)
c.stats.ChunksReadUnwanted++ c.stats.ChunksReadUnwanted++
c.t.stats.ChunksReadUnwanted++
return return
} }
@ -1087,6 +1088,9 @@ func (c *connection) receiveChunk(msg *pp.Message) {
piece := &t.pieces[index] piece := &t.pieces[index]
c.stats.ChunksReadUseful++ 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() c.lastUsefulChunkReceived = time.Now()
// if t.fastestConn != c { // if t.fastestConn != c {
// log.Printf("setting fastest connection %p", c) // log.Printf("setting fastest connection %p", c)

View File

@ -1514,6 +1514,9 @@ func (t *Torrent) pieceHashed(piece int, correct bool) {
} }
p.everHashed = true p.everHashed = true
if correct { if correct {
if len(touchers) != 0 {
t.stats.PiecesDirtiedGood++
}
for _, c := range touchers { for _, c := range touchers {
c.stats.PiecesDirtiedGood++ c.stats.PiecesDirtiedGood++
} }
@ -1523,6 +1526,7 @@ func (t *Torrent) pieceHashed(piece int, correct bool) {
} }
} else { } else {
if len(touchers) != 0 { if len(touchers) != 0 {
t.stats.PiecesDirtiedBad++
for _, c := range touchers { for _, c := range touchers {
// Y u do dis peer?! // Y u do dis peer?!
c.stats.PiecesDirtiedBad++ c.stats.PiecesDirtiedBad++