Example #1
0
        internal void ChangePicker(PiecePicker picker, BitField bitfield)
        {
            originalPicker = picker;
            if (UnhashedPieces.Length != bitfield.Length)
            {
                UnhashedPieces = new BitField(bitfield.Length);
            }

            picker = new IgnoringPicker(bitfield, picker);
            picker = new IgnoringPicker(UnhashedPieces, picker);
            Picker = picker;
        }
Example #2
0
        internal void ChangePicker(PiecePicker picker, BitField bitfield, ITorrentData data)
        {
            if (UnhashedPieces.Length != bitfield.Length)
            {
                UnhashedPieces = new BitField(bitfield.Length);
            }

            picker = new IgnoringPicker(bitfield, picker);
            picker = new IgnoringPicker(UnhashedPieces, picker);
            IEnumerable <Piece> pieces = Picker == null ? new List <Piece>() : Picker.ExportActiveRequests();

            picker.Initialise(bitfield, data, pieces);
            Picker = picker;
        }
 public PiecePickerTests()
 {
     // Yes, this is horrible. Deal with it.
     rig = TestRig.CreateMultiFile();
     peers = new List<PeerId>();
     picker = new IgnoringPicker(rig.Manager.Bitfield, new StandardPicker());
     picker.Initialise(rig.Manager.Bitfield, rig.Manager.Torrent.Files, new List<Piece>());
     peer = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     for (var i = 0; i < 20; i++)
     {
         var p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("tcp://" + i)), rig.Manager);
         p.SupportsFastPeer = true;
         peers.Add(p);
     }
 }
Example #4
0
        internal void ChangePicker(PiecePicker picker, BitField bitfield)
        {
            originalPicker = picker;
            if (PendingHashCheckPieces.Length != bitfield.Length)
            {
                PendingHashCheckPieces = new BitField(bitfield.Length);
            }

            // 'PendingHashCheckPieces' is the list of fully downloaded pieces which
            // are waiting to be hash checked. We should not begin a second download of
            // a piece while waiting to confirm if the original download was successful.
            //
            // 'Manager.UnhashedPieces' represents the pieces from the torrent which
            // have not been hash checked as they are marked as 'DoNotDownload'. If
            // a file is changed to be downloadable, the engine will hashcheck the data
            // first and then remove them from the 'UnhashedPieces' bitfield which will
            // make them downloadable. If they actually passed the hashcheck then they
            // won't actually be requested again.
            picker = new IgnoringPicker(bitfield, picker);
            picker = new IgnoringPicker(PendingHashCheckPieces, picker);
            picker = new IgnoringPicker(Manager.UnhashedPieces, picker);
            Picker = picker;
        }
        internal void ChangePicker(PiecePicker picker, BitField bitfield, TorrentFile[] files)
        {
            if (UnhashedPieces.Length != bitfield.Length)
                UnhashedPieces = new BitField(bitfield.Length);

            picker = new IgnoringPicker(bitfield, picker);
            picker = new IgnoringPicker(UnhashedPieces, picker);
            IEnumerable<Piece> pieces = Picker == null ? new List<Piece>() : Picker.ExportActiveRequests();
            picker.Initialise(bitfield, files, pieces);
            Picker = picker;
        }