]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Track failed piece hashes
authorMatt Joiner <anacrolix@gmail.com>
Sat, 13 Sep 2014 17:57:51 +0000 (03:57 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 13 Sep 2014 17:57:51 +0000 (03:57 +1000)
client.go

index 5b161293023a6cf163f76f034169d6c54900bd56..b8fbdb80d8d6623e21cbeab8a98cb15ff471d11b 100644 (file)
--- a/client.go
+++ b/client.go
@@ -56,6 +56,7 @@ var (
        unexpectedCancels           = expvar.NewInt("unexpectedCancels")
        postedCancels               = expvar.NewInt("postedCancels")
        duplicateConnsAvoided       = expvar.NewInt("duplicateConnsAvoided")
+       failedPieceHashes           = expvar.NewInt("failedPieceHashes")
 )
 
 const (
@@ -1451,6 +1452,10 @@ func (me *Client) DataWaiter(ih InfoHash, off int64) (ret <-chan struct{}) {
 
 func (me *Client) pieceHashed(t *torrent, piece pp.Integer, correct bool) {
        p := t.Pieces[piece]
+       if p.EverHashed && !correct {
+               log.Printf("%s: piece %d failed hash", t, piece)
+               failedPieceHashes.Add(1)
+       }
        p.EverHashed = true
        if correct {
                p.PendingChunkSpecs = nil