anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.39k stars 615 forks source link

Stop PRO tree traversal when allTorrentsUnverifiedBytes reaches MaxUnverifiedBytes #901

Closed veshij closed 5 months ago

veshij commented 5 months ago

If I understand correctly we should stop processing tree items once MaxUnverifiedBytes limit is reached. Existing implementation still goes through the whole tree resolving pointer to the torrent and calling t.IgnorePiece(_i.key.Index) for each piece.

while here moving storage check at the very end since it's quite unlikely it'll return False compared to MaxUnverifiedBytes or t.IgnorePiece().

anacrolix commented 5 months ago

I mentioned the short circuiting in https://github.com/anacrolix/torrent/issues/897#issuecomment-1931141820.

I believe it's correct to return false for that case. I don't think it will be faster (or correct) to move the other stuff around.