]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add choking/allowed fast checks to Peer.shouldRequest
authorMatt Joiner <anacrolix@gmail.com>
Sat, 18 Sep 2021 09:00:21 +0000 (19:00 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 18 Sep 2021 09:00:21 +0000 (19:00 +1000)
peerconn.go

index 4aee30fdbf557f712f5e2fa08c3d51a46a4e92b8..2174b0f620e677c68812abd010b95b3a711b68e4 100644 (file)
@@ -563,6 +563,9 @@ func (cn *Peer) shouldRequest(r Request) error {
        if cn.t.pieceQueuedForHash(pieceIndex(r.Index)) {
                panic("piece is queued for hash")
        }
+       if cn.peerChoking && !cn.peerAllowedFast.Contains(bitmap.BitIndex(r.Index)) {
+               panic("peer choking and piece not allowed fast")
+       }
        return nil
 }