コード例 #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);
            }
        }