Ejemplo n.º 1
0
        public void Setup()
        {
            // Three pieces of length 32kb.
            SmallTorrent = new TestTorrentData {
                Files       = new[] { new TorrentFile("foo", length: Piece.BlockSize * 2 * 3, startIndex: 0, endIndex: 2) },
                PieceLength = Piece.BlockSize * 2,
                Size        = Piece.BlockSize * 2 * 3,

                Bitfield = new BitField(3),
                Seeder   = PeerId.CreateNull(3, seeder: true, isChoking: false, amInterested: true)
            };

            // Three hundred pieces of length 4MB.
            LargeTorrent = new TestTorrentData {
                Files       = new[] { new TorrentFile("foo", length: Piece.BlockSize * 2 * 300, startIndex: 0, endIndex: 299) },
                PieceLength = Piece.BlockSize * 256,
                Size        = Piece.BlockSize * 256 * 300,

                Bitfield = new BitField(300),
                Seeder   = PeerId.CreateNull(300, seeder: true, isChoking: false, amInterested: true)
            };

            Standard = new StandardPicker();
            Endgame  = new EndGamePicker();
            Switcher = new EndGameSwitcher(Standard, Endgame, null);
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
        public void Initialise(ITorrentData torrentData, IReadOnlyList <BitField> ignoringBitfields)
        {
            TorrentData = torrentData;

            IPiecePicker picker = new StandardPicker();

            picker = new RandomisedPicker(picker);
            picker = new RarestFirstPicker(picker);
            picker = new PriorityPicker(picker);

            Picker = IgnoringPicker.Wrap(picker, ignoringBitfields);
            Picker.Initialise(torrentData);
        }
        public void Initialise(ITorrentData torrentData, IReadOnlyList <BitField> ignoringBitfields)
        {
            IgnorableBitfields = ignoringBitfields;
            TorrentData        = torrentData;

            Temp = new MutableBitField(TorrentData.PieceCount());

            IPiecePicker picker = new StandardPicker();

            picker = new RandomisedPicker(picker);
            picker = new RarestFirstPicker(picker);
            Picker = new PriorityPicker(picker);

            Picker.Initialise(torrentData);
        }
        public void Initialise(ITorrentData torrentData, IReadOnlyList <BitField> ignoringBitfields)
        {
            TorrentData = torrentData;

            var standardPicker = new StandardPicker();

            HighPriorityPicker = IgnoringPicker.Wrap(new PriorityPicker(standardPicker), ignoringBitfields);

            LowPriorityPicker = new RandomisedPicker(standardPicker);
            LowPriorityPicker = new RarestFirstPicker(LowPriorityPicker);
            LowPriorityPicker = new PriorityPicker(LowPriorityPicker);
            LowPriorityPicker = IgnoringPicker.Wrap(LowPriorityPicker, ignoringBitfields);

            LowPriorityPicker.Initialise(torrentData);
            HighPriorityPicker.Initialise(torrentData);
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
 public EndGameSwitcher(StandardPicker standard, EndGamePicker endgame, int blocksPerPiece, TorrentManager torrentManager)
     : this(standard, endgame, torrentManager)
 {
 }