Example #1
0
        public override void Initialise(ITorrentData torrentData)
        {
            base.Initialise(torrentData);

            allPrioritisedPieces = new MutableBitField(torrentData.PieceCount());
            temp = new MutableBitField(torrentData.PieceCount());

            files.Clear();
            for (int i = 0; i < torrentData.Files.Count; i++)
            {
                files.Add(new Files(torrentData.Files[i]));
            }
            BuildSelectors();
        }
Example #2
0
 public static int BytesPerPiece(this ITorrentData self, int pieceIndex)
 {
     if (pieceIndex < self.PieceCount() - 1)
     {
         return(self.PieceLength);
     }
     return((int)(self.Size - self.PieceIndexToByteOffset(pieceIndex)));
 }
Example #3
0
        public static int BlocksPerPiece(this ITorrentData self, int pieceIndex)
        {
            if (pieceIndex < self.PieceCount() - 1)
            {
                return(self.PieceLength / Piece.BlockSize);
            }

            var remainder = self.Size - self.PieceIndexToByteOffset(pieceIndex);

            return((int)((remainder + Piece.BlockSize - 1) / Piece.BlockSize));
        }
        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;
            IgnoringBitfields = ignoringBitfields;
            Temp = new MutableBitField(TorrentData.PieceCount());

            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);
        }