Fix piece failures not clearing dirty chunks

I don’t like how complicated piece completion/hashing management is, but it works.
This commit is contained in:
Matt Joiner 2016-12-06 16:10:10 +11:00
parent 2f9405bd8e
commit f510c5cf22
1 changed files with 16 additions and 13 deletions

View File

@ -1445,21 +1445,24 @@ func (t *Torrent) pieceHashed(piece int, correct bool) {
log.Printf("%T: error completing piece %d: %s", t.storage, piece, err)
}
t.updatePieceCompletion(piece)
} else if len(touchers) != 0 {
for _, c := range touchers {
// Y u do dis peer?!
c.badPiecesDirtied++
}
slices.Sort(touchers, connLessTrusted)
log.Printf("dropping first corresponding conn from trust: %v", func() (ret []int) {
} else {
if len(touchers) != 0 {
for _, c := range touchers {
ret = append(ret, c.netGoodPiecesDirtied())
// Y u do dis peer?!
c.badPiecesDirtied++
}
return
}())
c := touchers[0]
t.cl.banPeerIP(missinggo.AddrIP(c.remoteAddr()))
c.Drop()
slices.Sort(touchers, connLessTrusted)
log.Printf("dropping first corresponding conn from trust: %v", func() (ret []int) {
for _, c := range touchers {
ret = append(ret, c.netGoodPiecesDirtied())
}
return
}())
c := touchers[0]
t.cl.banPeerIP(missinggo.AddrIP(c.remoteAddr()))
c.Drop()
}
t.onIncompletePiece(piece)
}
}