Beispiel #1
0
        public void ReceivedBlock(BlockInfo blockInfo)
        {
            blocks[blockInfo.InPieceOffset] = BlockStatus.Received;

            receivedCount++;

            //            if(receivedCount==blocksCount)
            //            {
            //                complete = true;
            //
            //
            //            }
        }
Beispiel #2
0
        public void ReceiveBlock(BlockInfo block, byte[] data)
        {
            ActivePiece activePiece = activePieces[block.Piece];
            if (activePiece.WasRequested(block))
            {
                _dataManager.WriteBlock(_currContext.ToLocal(block), data);
                activePiece.ReceivedBlock(block);

                if (activePiece.Complete)
                {
                    PieceComplete(activePiece);
                }
            }
        }
Beispiel #3
0
 public static long GetInFilePosition(BlockInfo block)
 {
     return ((long) block.PieceIndex << StandardPieceSize) + block.InPieceOffset;
 }
Beispiel #4
0
 public bool WasRequested(BlockInfo blockInfo)
 {
     return blocks[blockInfo.InPieceOffset] == BlockStatus.Requested;
 }