Skip to content

Commit

Permalink
print hash rate
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Jul 18, 2024
1 parent e3be32d commit b2351e5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions t.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ func (t *Torrent) DownloadPieces(begin, end pieceIndex) {
var hashed atomic.Int64
var complete atomic.Int64
start := time.Now()
defer fmt.Println("DL", name, "DONE", "C:", complete.Load(), "H:", hashed.Load(), "HR:", float64(hashed.Load())/time.Since(start).Seconds())
defer func() {
fmt.Println("DL", name, "DONE", "C:", complete.Load(), "H:", hashed.Load(), "HR:", float64(hashed.Load())/time.Since(start).Seconds())
}()

for i := begin; i < end; i++ {
i := i
Expand All @@ -256,7 +258,7 @@ func (t *Torrent) DownloadPieces(begin, end pieceIndex) {

if completion.Complete {
complete.Add(int64(piece.length(true)))
fmt.Println("DL complete", complete.Load())
//fmt.Println("DL complete", complete.Load())
return nil
}

Expand All @@ -266,7 +268,7 @@ func (t *Torrent) DownloadPieces(begin, end pieceIndex) {

if checkCompletion && !storage.IsNew() {
hashed.Add(int64(piece.length(true)))
fmt.Println("DL hashed", hashed.Load())
//fmt.Println("DL hashed", hashed.Load())
if sum, _, err := t.hashPiece(piece); err == nil && sum == *piece.hash {
storage.MarkComplete(false)
t.updatePieceCompletion(i, true)
Expand Down

0 comments on commit b2351e5

Please sign in to comment.