From: Matt Joiner <anacrolix@gmail.com>
Date: Tue, 26 Oct 2021 03:42:42 +0000 (+1100)
Subject: Only assert pending requests when check is enabled
X-Git-Tag: v1.34.0^2~2
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=98957b6e8e879da532a9d609b97ad92d232a4134;p=btrtrc.git

Only assert pending requests when check is enabled

Uses too much CPU for production from its current callsites.
---

diff --git a/torrent.go b/torrent.go
index d606971d..5f18df1f 100644
--- a/torrent.go
+++ b/torrent.go
@@ -1408,6 +1408,9 @@ func (t *Torrent) numActivePeers() (num int) {
 }
 
 func (t *Torrent) assertPendingRequests() {
+	if !check {
+		return
+	}
 	var actual pendingRequests
 	if t.haveInfo() {
 		actual.m = make([]int, t.numRequests())