Beispiel #1
0
 public EndGameSwitcher(StandardPicker standard, EndGamePicker endgame, int blocksPerPiece, TorrentManager torrentManager)
     : base(null)
 {
     this.standard       = standard;
     this.endgame        = endgame;
     this.blocksPerPiece = blocksPerPiece;
     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 ChangePicker(PiecePicker picker)
        {
            Check.Picker(picker);

            ClientEngine.MainLoop.QueueWait((MainLoopTask) delegate {
                this._pieceManager.ChangePicker(picker, _bitfield, _torrent.Files);
            });
        }
Beispiel #4
0
        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);
            this._picker = picker;
        }
Beispiel #5
0
 internal PieceManager()
 {
     _picker         = new NullPicker();
     _unhashedPieces = new BitField(0);
 }
Beispiel #6
0
 protected PiecePicker(PiecePicker picker)
 {
     this.picker = picker;
 }
 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>());
     MessageBundle bundle = picker.PickPiece(peer, new Common.BitField(peer.BitField.Length), peers, 1, 0, peer.BitField.Length);
     Assert.IsNull(bundle);
 }
Beispiel #8
0
 protected PiecePicker(PiecePicker picker)
 {
     this.picker = picker;
 }
Beispiel #9
0
 public PriorityPicker(PiecePicker picker)
     : base(picker)
 {
 }
        private int ratio = 4; // ratio from medium priority to high priority set size

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Empty constructor for changing piece pickers
        /// </summary>
        public SlidingWindowPicker(PiecePicker picker)
            : base(picker)
        {
        }
Beispiel #11
0
 /// <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="bitField">The bitfield associated with the torrent</param>
 /// <param name="torrentFiles">The files that are available in this torrent</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;
 }
Beispiel #12
0
 /// <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="bitField">The bitfield associated with the torrent</param>
 /// <param name="torrentFiles">The files that are available in this torrent</param>
 /// <param name="highPrioritySetSize">Size of high priority set</param>
 internal SlidingWindowPicker(PiecePicker picker, int highPrioritySetSize)
     : this(picker, highPrioritySetSize, 4)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Empty constructor for changing piece pickers
 /// </summary>
 public SlidingWindowPicker(PiecePicker picker)
     : base(picker)
 {
 }
 public RarestFirstPicker(PiecePicker picker)
     : base(picker)
 {
     rarest = new Stack <BitField>();
     spares = new Stack <BitField>();
 }
Beispiel #15
0
 public IgnoringPicker(BitField bitfield, PiecePicker picker)
     : base(picker)
 {
     this.bitfield = bitfield;
     this.temp = new BitField(bitfield.Length);
 }
Beispiel #16
0
 public IgnoringPicker(BitField bitfield, PiecePicker picker)
     : base(picker)
 {
     this.bitfield = bitfield;
     this.temp     = new BitField(bitfield.Length);
 }
 /// <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="bitField">The bitfield associated with the torrent</param>
 /// <param name="torrentFiles">The files that are available in this torrent</param>
 /// <param name="highPrioritySetSize">Size of high priority set</param>
 internal SlidingWindowPicker(PiecePicker picker, int highPrioritySetSize)
     : this(picker, highPrioritySetSize, 4)
 {
 }
 public RarestFirstPicker(PiecePicker picker)
     : base(picker)
 {
     rarest = new Stack<BitField>();
     spares = new Stack<BitField>();
 }
 /// <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="bitField">The bitfield associated with the torrent</param>
 /// <param name="torrentFiles">The files that are available in this torrent</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;
 }
Beispiel #20
0
 public RandomisedPicker(PiecePicker picker)
     : base(picker)
 {
 }
Beispiel #21
0
        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);
            this.picker = picker;
        }
 public virtual void Setup()
 {
     // 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 (int i = 0; i < 20; i++)
     {
         PeerId p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("tcp://" + i)), rig.Manager);
         p.SupportsFastPeer = true;
         peers.Add(p);
     }
 }
Beispiel #23
0
 internal PieceManager()
 {
     picker = new NullPicker();
     unhashedPieces = new BitField(0);
 }
Beispiel #24
0
 public LoggingPicker(PiecePicker picker)
     : base(picker)
 {
 }
Beispiel #25
0
 public RandomisedPicker(PiecePicker picker)
     : base(picker)
 {
 }