From: Matt Joiner Date: Sun, 5 Nov 2017 04:27:21 +0000 (+1100) Subject: Kick connections requesting pieces we don't have X-Git-Tag: v1.0.0~352 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=be33fc44765c2768e56f99351239c2bdb59a6d2d;p=btrtrc.git Kick connections requesting pieces we don't have This was removed at some point, and made the requests received for missing pieces expvar unused. --- 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 {