public EndGameSwitcher(PiecePicker standard, EndGamePicker endgame, TorrentManager torrentManager)
     : base(null)
 {
     this.standard       = standard;
     this.endgame        = endgame;
     this.torrentManager = torrentManager;
 }
 public EndGameSwitcher(StandardPicker standard, EndGamePicker endgame, int blocksPerPiece, TorrentManager torrentManager)
     : base(null)
 {
     this.standard       = standard;
     this.endgame        = endgame;
     this.blocksPerPiece = blocksPerPiece;
     this.torrentManager = torrentManager;
 }
Beispiel #3
0
        public void DoesntHaveSuggestedPiece()
        {
            peer.IsChoking        = false;
            peer.SupportsFastPeer = true;
            peer.SuggestedPieces.AddRange(new int[] { 1, 2, 3, 4 });
            peer.BitField.SetAll(true);
            picker = new StandardPicker();
            picker.Initialise(rig.Manager.Bitfield, rig.Torrent.Files, new List <Piece>());
            var bundle = picker.PickPiece(peer, new BitField(peer.BitField.Length), peers, 1, 0, peer.BitField.Length);

            Assert.IsNull(bundle);
        }
        public void DoesntHaveFastPiece()
        {
            peer.IsChoking        = true;
            peer.SupportsFastPeer = true;
            peer.IsAllowedFastPieces.AddRange(new[] { 1, 2, 3, 4 });
            peer.BitField.SetAll(true);
            picker = new StandardPicker();
            picker.Initialise(bitfield, torrentData, new List <Piece> ());
            var bundle = picker.PickPiece(peer, new BitField(peer.BitField.Length), peers, 1, 0, peer.BitField.Length);

            Assert.IsNull(bundle);
        }
Beispiel #5
0
        public virtual void Setup()
        {
            // Yes, this is horrible. Deal with it.
            rig   = TestRig.CreateMultiFile();
            peers = new List <PeerId>();

            manager = new PieceManager();
            manager.ChangePicker((standardPicker = new StandardPicker()), rig.Manager.Bitfield, rig.Manager.Torrent.Files);
            this.picker = manager.Picker;

            peer = new PeerId(new Peer(new string('a', 20), new Uri("ipv4://BLAH")), rig.Manager, NullConnection.Incoming);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("ipv4://" + i)), rig.Manager, NullConnection.Incoming);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
        public void Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;

            bitfield    = new BitField(pieceCount);
            torrentData = new TestTorrentData {
                Files       = new[] { new TorrentFile("File", pieceLength * pieceCount) },
                PieceLength = pieceLength,
                Size        = pieceLength * pieceCount
            };
            peers = new List <PeerId> ();

            picker = new StandardPicker();
            picker.Initialise(bitfield, torrentData, Enumerable.Empty <Piece> ());

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
 /// <summary>
 /// Create a new SlidingWindowPicker with the given set sizes. The sliding window will be positioned to the start
 /// of the first file to be downloaded
 /// </summary>
 /// <param name="picker">The picker which requests should be forwarded to</param>
 /// <param name="highPrioritySetSize">Size of high priority set</param>
 /// <param name="mediumToHighRatio">Size of medium priority set as a multiple of the high priority set size</param>
 internal SlidingWindowPicker(PiecePicker picker, int highPrioritySetSize, int mediumToHighRatio)
     : base(picker)
 {
     this.highPrioritySetSize = highPrioritySetSize;
     this.ratio = mediumToHighRatio;
 }
 /// <summary>
 /// Creates a new piece picker with support for prioritization of files. The sliding window will be positioned to the start
 /// of the first file to be downloaded
 /// </summary>
 /// <param name="picker">The picker which requests should be forwarded to</param>
 /// <param name="highPrioritySetSize">Size of high priority set</param>
 internal SlidingWindowPicker(PiecePicker picker, int highPrioritySetSize)
     : this(picker, highPrioritySetSize, 4)
 {
 }
 /// <summary>
 /// Empty constructor for changing piece pickers
 /// </summary>
 public SlidingWindowPicker(PiecePicker picker)
     : base(picker)
 {
 }
Beispiel #10
0
 public IgnoringPicker(BitField bitfield, PiecePicker picker)
     : base(picker)
 {
     Bitfield = bitfield;
     Temp     = new BitField(bitfield.Length);
 }
 public RandomisedPicker(PiecePicker picker)
     : base(picker)
 {
 }
 public PriorityPicker(PiecePicker picker)
     : base(picker)
 {
 }
Beispiel #13
0
 public RarestFirstPicker(PiecePicker picker)
     : base(picker)
 {
     rarest = new Stack <BitField> ();
     spares = new Stack <BitField> ();
 }
Beispiel #14
0
 /// <summary>
 /// Empty constructor for changing piece pickers
 /// </summary>
 public StreamingPiecePicker(PiecePicker picker)
     : base(new PriorityPicker(picker))
 {
     LowPriorityPicker = new PriorityPicker(new RarestFirstPicker(new RandomisedPicker(picker)));
 }
Beispiel #15
0
 protected PiecePicker(PiecePicker picker)
 {
     this.picker = picker;
 }
Beispiel #16
0
 protected PiecePicker(PiecePicker picker)
 {
     BasePicker = picker;
 }