dirtyChunks roaring.Bitmap
pex pexState
+
+ // Is On when all pieces are complete.
+ Complete chansync.Flag
}
func (t *Torrent) pieceAvailabilityFromPeers(i pieceIndex) (count int) {
t.nameMu.Lock()
t.info = info
t.nameMu.Unlock()
+ t.updateComplete()
t.fileIndex = segments.NewIndex(common.LengthIterFromUpvertedFiles(info.UpvertedFiles()))
t.displayName = "" // Save a few bytes lol.
t.initFiles()
} else {
t._completedPieces.Remove(x)
}
+ t.updateComplete()
if complete && len(p.dirtiers) != 0 {
t.logger.Printf("marked piece %v complete but still has dirtiers", piece)
}
func (t *Torrent) pieceRequestIndexOffset(piece pieceIndex) RequestIndex {
return RequestIndex(piece) * t.chunksPerRegularPiece()
}
+
+func (t *Torrent) updateComplete() {
+ t.Complete.SetBool(t.haveAllPieces())
+}