ExportActiveRequests() public method

public ExportActiveRequests ( ) : List
return List
Ejemplo n.º 1
0
        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);
            foreach (var t in _files.Where(t => t.Priority != Priority.DoNotDownload))
            {
                _endgameSelector.Or(t.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.
            var pieces = _standard.ExportActiveRequests();
            var count  = pieces.Sum(t => t.TotalReceived);

            _inEndgame = Math.Max(_blocksPerPiece, (_endgameSelector.TrueCount * _blocksPerPiece)) - count < Threshold;
            if (_inEndgame)
            {
                _endgame.Initialise(_bitfield, _files, _standard.ExportActiveRequests());
                // Set torrent's IsInEndGame flag
                _torrentManager.InternalIsInEndGame = true;
            }
            return(_inEndgame);
        }
Ejemplo n.º 2
0
 public virtual List <Piece> ExportActiveRequests()
 {
     CheckOverriden();
     return(_picker.ExportActiveRequests());
 }