]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix requests to other leechers
authorMatt Joiner <anacrolix@gmail.com>
Thu, 20 Mar 2014 13:11:49 +0000 (00:11 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 20 Mar 2014 13:11:49 +0000 (00:11 +1100)
client.go

index 629b708b7f6bc3544c6b6cfb9b450f793b8fb335..1c02c25f9cedeafead33e6da16b5367291584cc6 100644 (file)
--- a/client.go
+++ b/client.go
@@ -131,12 +131,12 @@ func (c *Connection) Post(msg encoding.BinaryMarshaler) {
 
 // Returns true if more requests can be sent.
 func (c *Connection) Request(chunk Request) bool {
-       if !c.PeerPieces[chunk.Index] {
-               panic("peer doesn't have that piece!")
-       }
        if len(c.Requests) >= maxRequests {
                return false
        }
+       if !c.PeerPieces[chunk.Index] {
+               return true
+       }
        c.SetInterested(true)
        if c.PeerChoked {
                return false