From be33fc44765c2768e56f99351239c2bdb59a6d2d Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 5 Nov 2017 15:27:21 +1100 Subject: [PATCH] Kick connections requesting pieces we don't have This was removed at some point, and made the requests received for missing pieces expvar unused. --- connection.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/connection.go b/connection.go index b1ced800..3667cf7a 100644 --- a/connection.go +++ b/connection.go @@ -823,6 +823,15 @@ func (c *connection) mainReadLoop() error { break } if len(c.PeerRequests) >= maxRequests { + // TODO: Should we drop them or Choke them instead? + break + } + if !t.havePiece(msg.Index.Int()) { + // This isn't necessarily them screwing up. We can drop pieces + // from our storage, and can't communicate this to peers + // except by reconnecting. + requestsReceivedForMissingPieces.Add(1) + err = errors.New("peer requested piece we don't have") break } if c.PeerRequests == nil { -- 2.48.1