]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Kick connections requesting pieces we don't have
authorMatt Joiner <anacrolix@gmail.com>
Sun, 5 Nov 2017 04:27:21 +0000 (15:27 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 5 Nov 2017 04:39:36 +0000 (15:39 +1100)
This was removed at some point, and made the requests received for missing pieces expvar unused.

connection.go

index b1ced80084ad657b55446f02931e304340e676c1..3667cf7ad20fa3c98f69020e7645443998724179 100644 (file)
@@ -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 {