From: Matt Joiner Date: Wed, 23 Nov 2016 00:52:41 +0000 (+1100) Subject: Add a note about dropping connections that we sent a HAVE for incomplete pieces X-Git-Tag: v1.0.0~529 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=57b679ffb07e207ca198b3c4165b8dd091ef1b6d;p=btrtrc.git Add a note about dropping connections that we sent a HAVE for incomplete pieces --- diff --git a/connection.go b/connection.go index 3ba41076..94451c6d 100644 --- a/connection.go +++ b/connection.go @@ -1060,3 +1060,11 @@ another: } c.Choke() } + +func (cn *connection) Drop() { + cn.t.dropConnection(cn) +} + +func (cn *connection) sentHave(piece int) bool { + return piece < len(cn.sentHaves) && cn.sentHaves[piece] +} diff --git a/torrent.go b/torrent.go index f6f723bf..89422917 100644 --- a/torrent.go +++ b/torrent.go @@ -1469,6 +1469,16 @@ func (t *Torrent) onIncompletePiece(piece int) { if !t.wantPieceIndex(piece) { return } + // We could drop any connections that we told we have a piece that we + // don't here. But there's a test failure, and it seems clients don't care + // if you request pieces that you already claim to have. Pruning bad + // connections might just remove any connections that aren't treating us + // favourably anyway. + // for c := range t.conns { + // if c.sentHave(piece) { + // c.Drop() + // } + // } for conn := range t.conns { if conn.PeerHasPiece(piece) { conn.updateRequests()