]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Filter next requests application for peer state changes
authorMatt Joiner <anacrolix@gmail.com>
Mon, 20 Sep 2021 04:16:55 +0000 (14:16 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 20 Sep 2021 04:16:55 +0000 (14:16 +1000)
requesting.go

index 7e42babacf5ccf087b28bcc70b067aab72eebe54..3d29d48173a2b62980fcdee729940cf85d8f2526 100644 (file)
@@ -132,6 +132,11 @@ func (p *Peer) applyNextRequestState() bool {
                }
        }
        for req := range next.Requests {
+               // This could happen if the peer chokes us between the next state being generated, and us
+               // trying to transmit the state.
+               if p.peerChoking && !p.peerAllowedFast.Contains(bitmap.BitIndex(req.Index)) {
+                       continue
+               }
                more, err := p.request(req)
                if err != nil {
                        panic(err)