public override void Reset() { inEndgame = false; torrentManager.isInEndGame = false; standard.Reset(); endgame.Reset(); }
private bool TryEnableEndgame() { if (inEndgame) { return(false); } // We need to activate endgame mode when there are less than 20 requestable blocks // available. We OR the bitfields of all the files which are downloadable and then // NAND it with the torrents bitfield to get a list of pieces which remain to be downloaded. // Essentially we get a list of all the pieces we're allowed download, then get a list of // the pieces which we still need to get and AND them together. // Create the bitfield of pieces which are downloadable endgameSelector.SetAll(false); for (int i = 0; i < torrentData.Files.Length; i++) { if (torrentData.Files[i].Priority != Priority.DoNotDownload) { endgameSelector.Or(torrentData.Files[i].GetSelector(bitfield.Length)); } } // NAND it with the pieces we already have (i.e. AND it with the pieces we still need to receive) endgameSelector.NAnd(bitfield); // If the total number of blocks remaining is less than Threshold, activate Endgame mode. int count = standard.CurrentReceivedCount(); int blocksPerPiece = torrentData.PieceLength / Piece.BlockSize; inEndgame = Math.Max(blocksPerPiece, (endgameSelector.TrueCount * blocksPerPiece)) - count <= Threshold; if (inEndgame) { endgame.Initialise(bitfield, torrentData, standard.ExportActiveRequests()); standard.Reset(); // Set torrent's IsInEndGame flag if (torrentManager != null) { torrentManager.isInEndGame = true; } } return(inEndgame); }
public override void Reset() { inEndgame = false; if (torrentManager != null) { torrentManager.isInEndGame = false; } standard.Reset(); endgame.Reset(); }
public virtual void Reset() { CheckOverriden(); picker.Reset(); }