コード例 #1
0
        public void Setup()
        {
            var pieceCount  = 40;
            var pieceLength = 256 * 1024;

            torrentData = new TestTorrentData {
                Files       = new[] { new TorrentFileInfo(new TorrentFile("One File", pieceLength * pieceCount, 0, pieceCount)) },
                PieceLength = pieceLength,
                Size        = pieceLength * pieceCount
            };

            bitfield = new BitField(torrentData.PieceCount)
                       .SetAll(true)
                       .Set(4, false)
                       .Set(6, false)
                       .Set(24, false)
                       .Set(36, false);

            picker = new EndGamePicker();
            pieces = new List <Piece> (new[] {
                new Piece(4, torrentData.PieceLength, torrentData.Size),
                new Piece(6, torrentData.PieceLength, torrentData.Size),
                new Piece(24, torrentData.PieceLength, torrentData.Size),
                new Piece(36, torrentData.PieceLength, torrentData.Size)
            });

            id           = PeerId.CreateNull(torrentData.PieceCount);
            id.IsChoking = false;

            other           = PeerId.CreateNull(torrentData.PieceCount);
            other.IsChoking = false;
        }
コード例 #2
0
 public EndGameSwitcher(PiecePicker standard, EndGamePicker endgame, TorrentManager torrentManager)
     : base(null)
 {
     this.standard       = standard;
     this.endgame        = endgame;
     this.torrentManager = torrentManager;
 }
コード例 #3
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);
        }
コード例 #4
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;
 }
コード例 #5
0
 public EndGameSwitcher(StandardPicker standard, EndGamePicker endgame, int blocksPerPiece, TorrentManager torrentManager)
     : this(standard, endgame, torrentManager)
 {
 }