Exemplo n.º 1
0
 private void ParsePieceHashes(byte[] hashdata)
 {
     int targetPieces = hashdata.Length / 20;
     pieces = 0; // reset! careful
     pieceArray = null;
     pieceArray = new Piece[targetPieces];
     while (pieces < targetPieces)
     {
         Piece p = new Piece(this, pieces);
         pieceArray[pieces] = p;
         pieces++;
     }
 }
Exemplo n.º 2
0
		public void SendPieceRequestToPeer( Peer peer, int pieceId, int begin, int length )
		{
			if ( !this.mDownloadingPeers.Contains( peer ) )
				this.mDownloadingPeers.Add( peer );
			if ( this.mPeersAvailableToDownload.Contains( peer ) )
				this.mPeersAvailableToDownload.Remove( peer );

			if ( !mCurrentlyDownloadingPieces.ContainsKey( pieceId ) )
			{
				Piece piece = new Piece( this.mTorrent.Metainfo, pieceId );
				mCurrentlyDownloadingPieces.Add( pieceId, piece );
			}

			peer.SendPieceRequest( pieceId, begin, length );
		}