示例#1
0
        public async Task Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;
            var torrentData = TestTorrentManagerInfo.Create(
                files: TorrentFileInfo.Create(pieceLength, ("File", pieceLength * pieceCount, "full/path/File")),
                pieceLength: pieceLength,
                size: pieceLength * pieceCount
                );

            peers = new List <PeerId> ();

            torrentManager = TestRig.CreateSingleFileManager(torrentData.TorrentInfo.Size, torrentData.TorrentInfo.PieceLength);
            await torrentManager.LoadFastResumeAsync(new FastResume (torrentManager.InfoHashes, new BitField(pieceCount).SetAll(true), new BitField(pieceCount).SetAll(false)));

            manager = new PieceManager(torrentManager);
            manager.Initialise();

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
示例#2
0
        public void Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;
            var torrentData = new TestTorrentData {
                Files       = TorrentFileInfo.Create(pieceLength, ("File", pieceLength * pieceCount, "full/path/File")),
                PieceLength = pieceLength,
                Size        = pieceLength * pieceCount
            };

            peers = new List <PeerId> ();

            torrentManager = TestRig.CreateSingleFileManager(torrentData.Size, torrentData.PieceLength);
            torrentManager.LoadFastResume(new FastResume(torrentManager.InfoHash, new BitField(pieceCount).SetAll(true), new BitField(pieceCount).SetAll(false)));

            manager = new PieceManager(torrentManager);
            manager.Initialise();

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
示例#3
0
        public void Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;

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

            torrentManager = TestRig.CreateSingleFileManager(torrentData.Size, torrentData.PieceLength);
            torrentManager.LoadFastResume(new FastResume(torrentManager.InfoHash, new BitField(pieceCount).SetAll(true), new BitField(pieceCount).SetAll(false)));
            manager = new PieceManager(torrentManager);
            manager.ChangePicker(new StandardPicker(), bitfield);
            manager.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);
            }
        }