]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use ignorePieceForRequests instead of shady pending pieces
authorMatt Joiner <anacrolix@gmail.com>
Tue, 12 Aug 2025 14:28:21 +0000 (00:28 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 12 Aug 2025 14:28:21 +0000 (00:28 +1000)
torrent.go

index 3436e9ece3a9fd4a6a221895c8572b075cf76da9..9c8d534f64961994bc35f21b415dafec92bab76f 100644 (file)
@@ -1323,7 +1323,6 @@ func (t *Torrent) hashPieceWithSpecificHash(piece pieceIndex, h hash.Hash) (
        storagePiece := p.Storage()
        var written int64
        written, err = storagePiece.WriteTo(w)
-       // TODO: Require the correct number of bytes were written to pass hash.
        t.countBytesHashed(written)
        return
 }
@@ -2662,7 +2661,7 @@ func (t *Torrent) onIncompletePiece(piece pieceIndex) {
        if t.pieceAllDirty(piece) {
                t.pendAllChunkSpecs(piece)
        }
-       if !t.wantPieceIndex(piece) {
+       if t.ignorePieceForRequests(piece) {
                // t.logger.Printf("piece %d incomplete and unwanted", piece)
                return
        }
@@ -3564,7 +3563,7 @@ func (t *Torrent) endRequestIndexForFileIndex(fileIndex int) RequestIndex {
 
 func (t *Torrent) wantReceiveChunk(reqIndex RequestIndex) bool {
        pi := t.pieceIndexOfRequestIndex(reqIndex)
-       if !t.wantPieceIndex(pi) {
+       if t.ignorePieceForRequests(pi) {
                return false
        }
        if t.haveRequestIndexChunk(reqIndex) {