From: Matt Joiner <anacrolix@gmail.com>
Date: Wed, 8 Jan 2020 22:51:36 +0000 (+1100)
Subject: Improve hash piece error logging
X-Git-Tag: v1.12.0~18
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=bf0498ed5a6fde570cbe3b806f3dae12d1838827;p=btrtrc.git

Improve hash piece error logging
---

diff --git a/torrent.go b/torrent.go
index 51ef3681..caeb8c23 100644
--- a/torrent.go
+++ b/torrent.go
@@ -749,7 +749,7 @@ func (t *Torrent) hashPiece(piece pieceIndex) (ret metainfo.Hash, copyErr error)
 	p.waitNoPendingWrites()
 	ip := t.info.Piece(int(piece))
 	pl := ip.Length()
-	_, copyErr = io.CopyN(hash, io.NewSectionReader(t.pieces[piece].Storage(), 0, pl), pl)
+	_, copyErr = io.Copy(hash, io.NewSectionReader(t.pieces[piece].Storage(), 0, pl))
 	missinggo.CopyExact(&ret, hash.Sum(nil))
 	return
 }
@@ -1658,7 +1658,7 @@ func (t *Torrent) pieceHasher(index pieceIndex) {
 	sum, copyErr := t.hashPiece(index)
 	correct := sum == *p.hash
 	if !correct {
-		log.Fmsg("piece %v hash failure copy error: %v", index, copyErr).Log(t.logger)
+		log.Fmsg("piece %v (%s) hash failure copy error: %v", p, p.hash.HexString(), copyErr).Log(t.logger)
 	}
 	t.storageLock.RUnlock()
 	t.cl.lock()