Exemplo n.º 1
0
        public void Setup()
        {
            int pieceLength = 16 * Piece.BlockSize;
            int pieces      = 40;
            int size        = pieces * pieceLength;

            bitfield    = new BitField(pieces);
            torrentData = new TestTorrentData {
                Files       = new [] { new TorrentFile("Test", size) },
                PieceLength = pieceLength,
                Size        = size
            };

            checker = new TestPicker();
            picker  = new RarestFirstPicker(checker);
            picker.Initialise(bitfield, torrentData, new List <Piece>());

            peer = PeerId.CreateNull(pieces);
            peer.BitField.SetAll(true);

            peers = new List <PeerId>();
            for (int i = 0; i < 5; i++)
            {
                peers.Add(PeerId.CreateNull(pieces));
            }
        }
        public void Setup()
        {
            int pieceLength = 16 * Piece.BlockSize;
            int pieces      = 40;
            int size        = pieces * pieceLength;

            bitfield    = new MutableBitField(pieces);
            torrentData = new TestTorrentData {
                Files       = TorrentFileInfo.Create(pieceLength, ("Test", size, "Full/Path/Test")),
                PieceLength = pieceLength,
                Size        = size
            };

            checker = new PiecePickerFilterChecker();
            picker  = new RarestFirstPicker(checker);
            picker.Initialise(torrentData);

            peer = PeerId.CreateNull(pieces);
            peer.MutableBitField.SetAll(true);

            peers = new List <PeerId> ();
            for (int i = 0; i < 5; i++)
            {
                peers.Add(PeerId.CreateNull(pieces));
            }
        }
Exemplo 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);
        }
Exemplo n.º 6
0
        public void Setup()
        {
            tester = new TestPicker();
            rarest = new RarestFirstPicker(tester);
            rarest.Initialise(rig.Manager.Bitfield, rig.Torrent.Files, new List <Piece>());
            peers = new List <PeerId>();
            for (int i = 0; i < 5; i++)
            {
                peers.Add(new PeerId(new Peer(new string((char)(i + 'a'), 20), new Uri("ipv4://aaa")), rig.Manager, NullConnection.Incoming));
            }

            for (int i = 0; i < rig.Manager.Bitfield.Length; i++)
            {
                for (int j = 0; j < peers.Count; j++)
                {
                    peers[j].BitField[i] = i % (j + 1) == 0;
                }
            }
            peers[0].BitField.SetAll(true);
        }