From: Matt Joiner Date: Sat, 18 Sep 2021 09:00:21 +0000 (+1000) Subject: Add choking/allowed fast checks to Peer.shouldRequest X-Git-Tag: v1.32.0~34 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d90c41c53481d37c1dfcc4a9da4ba48b5cd4a53d;p=btrtrc.git Add choking/allowed fast checks to Peer.shouldRequest --- diff --git a/peerconn.go b/peerconn.go index 4aee30fd..2174b0f6 100644 --- a/peerconn.go +++ b/peerconn.go @@ -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 }