]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent.go
Don't verify data at startup, add Torrent.Piece.VerifyData and Torrent.VerifyData...
[btrtrc.git] / torrent.go
index 5d6be261d7987af179f555a4c7ac28953724dff2..29ca25a66aa4075f981a9b5b47856ee180f4d2cd 100644 (file)
@@ -284,13 +284,13 @@ func (t *Torrent) setInfoBytes(b []byte) error {
        }
        for i := range t.pieces {
                t.updatePieceCompletion(i)
-               t.pieces[i].QueuedForHash = true
+               // t.pieces[i].QueuedForHash = true
        }
-       go func() {
-               for i := range t.pieces {
-                       t.verifyPiece(i)
-               }
-       }()
+       // go func() {
+       //      for i := range t.pieces {
+       //              t.verifyPiece(i)
+       //      }
+       // }()
        return nil
 }
 
@@ -1485,6 +1485,7 @@ func (t *Torrent) verifyPiece(piece int) {
        cl.mu.Unlock()
        sum := t.hashPiece(piece)
        cl.mu.Lock()
+       p.numVerifies++
        p.Hashing = false
        t.pieceHashed(piece, sum == p.Hash)
 }
@@ -1518,3 +1519,9 @@ func (t *Torrent) queuePieceCheck(pieceIndex int) {
        t.publishPieceChange(pieceIndex)
        go t.verifyPiece(pieceIndex)
 }
+
+func (t *Torrent) VerifyData() {
+       for i := range iter.N(t.NumPieces()) {
+               t.Piece(i).VerifyData()
+       }
+}