internal void RaisePieceHashed(PieceHashedEventArgs args)
        {
            int index = args.PieceIndex;

            TorrentFile[] files = this.torrent.Files;

            for (int i = 0; i < files.Length; i++)
            {
                if (index >= files[i].StartPieceIndex && index <= files[i].EndPieceIndex)
                {
                    files[i].BitField[index - files[i].StartPieceIndex] = args.HashPassed;
                }
            }

            if (args.HashPassed)
            {
                List <PeerId> connected = Peers.ConnectedPeers;
                for (int i = 0; i < connected.Count; i++)
                {
                    connected[i].IsAllowedFastPieces.Remove(index);
                }
            }

            Toolbox.RaiseAsyncEvent <PieceHashedEventArgs>(PieceHashed, this, args);
        }
Exemple #2
0
 private void PieceHashed(object sender, PieceHashedEventArgs e)
 {
     if (e.TorrentManager.State != TorrentState.Hashing)
     {
         diskManager.QueueFlush(e.TorrentManager, e.PieceIndex);
     }
 }
        internal void HashedPiece(PieceHashedEventArgs pieceHashedEventArgs)
        {
            if (!pieceHashedEventArgs.HashPassed)
            {
                Interlocked.Increment(ref this.hashFails);
            }

            RaisePieceHashed(pieceHashedEventArgs);
        }
        internal void HashedPiece(PieceHashedEventArgs pieceHashedEventArgs)
        {
            if (!pieceHashedEventArgs.HashPassed)
            {
                HashFails++;
            }

            RaisePieceHashed(pieceHashedEventArgs);
        }
 private void PieceHashed(object sender, PieceHashedEventArgs e)
 {
     if (e.TorrentManager.State != TorrentState.Hashing)
         diskManager.QueueFlush(e.TorrentManager, e.PieceIndex);
 }
Exemple #6
0
        private void PieceHashed(object sender, PieceHashedEventArgs e)
        {
            int pieceIndex = e.PieceIndex;
            int totalPieces = e.TorrentManager.Torrent.Pieces.Count;

            lock (_lock)
            {
                _progress = (double)pieceIndex / totalPieces * 100.0;
            }
        }
Exemple #7
0
 void wrapper_PieceHashed(object sender, PieceHashedEventArgs e)
 {
     if (RecievedPieces == null)
     {
         RecievedPieces = new bool[Torrent.Torrent.Pieces.Count];
         for (int i = 0; i < RecievedPieces.Length; i++)
             RecievedPieces[i] = false;
     }
     if (e.HashPassed)
         RecievedPieces[e.PieceIndex] = true;
 }
 private void OnPieceHashed(object sender, PieceHashedEventArgs e)
 {
     float progress = EnumAdapter.Adapt(manager.State) == TorrentState.Hashing ? (float)e.PieceIndex / manager.Bitfield.Length : 1;
     PieceHashedHandler h = PieceHashed;
     if (h != null)
         h (Path, e.PieceIndex, e.HashPassed, progress);
 }
 public static void HandlePieceHashed(object sender, PieceHashedEventArgs e)
 {
     var torrentManager = e.TorrentManager;
     if (torrentManager.State == TorrentState.Downloading && e.HashPassed) {
         logger.DebugFormat("Torrent {0}: downloaded piece {1}.",
             torrentManager.Torrent.Name, e.PieceIndex);
     }
 }
        private void manager_PieceHashed(object sender, PieceHashedEventArgs args)
        {
            try {
                if (manager.State == TorrentState.Hashing) {
                    hashingPercent = (((double)args.PieceIndex / (double)manager.Torrent.Pieces.Count) * 100);
                }

                #if RIDICULOUS_DEBUG_OUTPUT
                LoggingService.LogDebug("Piece Hashed!");
                #endif
            } catch (Exception ex) {
                LoggingService.LogError("Error in manager_PieceHashed.", ex);
                this.Cancel();
            }
        }
		private void OnPieceHashed (object sender, PieceHashedEventArgs args)
		{
	
			if(!hashProgress.ContainsKey(args.TorrentManager))
				hashProgress.Add(args.TorrentManager, 0);
			else
				hashProgress[args.TorrentManager] = (int) ((args.PieceIndex / (float)args.TorrentManager.Torrent.Pieces.Count) * 100);
			
			// remove hashed piece from pieces
			foreach (BlockEventArgs blockEvent in pieces) {
				
				if (blockEvent.Piece.Index != args.PieceIndex){
					pieces.Remove(blockEvent);
					return;
				}
			}
		}
Exemple #12
0
 private void PieceHashed(object sender, PieceHashedEventArgs e)
 {
     diskManager.QueueFlush(e.TorrentManager, e.PieceIndex);
 }
 private void TorrentManager_PieceHashed(object sender, PieceHashedEventArgs e)
 {
     var dowloaded = e.TorrentManager.Monitor.DataBytesDownloaded;
     var downloadspeed = e.TorrentManager.Monitor.DownloadSpeed;
 }
        void torrent_PieceHashed(object sender, PieceHashedEventArgs e)
        {
            lock (currentRequests)
            {
                for (int i = 0; i < this.currentRequests.Count; i++)
                {
                    if (this.currentRequests[i].Piece.Index == e.PieceIndex)
                        continue;

                    this.currentRequests.RemoveAt(i);
                    break;
                }
            }
        }