connection.go | 8 ++++++++ torrent.go | 10 ++++++++++ diff --git a/connection.go b/connection.go index 3ba41076fbe3ba895adc0a754e08dd6b84c04a4b..94451c6de6d6939dda04e1f72aef6f30d116cb01 100644 --- a/connection.go +++ b/connection.go @@ -1060,3 +1060,11 @@ return } 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 f6f723bf42b74a5eb553f442ec4161a77830ff49..89422917de494b24ecb03724c0b2c5214881db94 100644 --- a/torrent.go +++ b/torrent.go @@ -1469,6 +1469,16 @@ } 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()