From 8b90e737c8a64e58d943339c84a7d8009ee58418 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 12 Oct 2021 13:06:59 +1100 Subject: [PATCH] Panic if pending request count goes negative in requesting --- requesting.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requesting.go b/requesting.go index d4311413..c1575885 100644 --- a/requesting.go +++ b/requesting.go @@ -144,6 +144,12 @@ func (p *peerRequests) Less(i, j int) bool { if current { ret-- } + // I have a hunch that this could trigger for requests for chunks that are choked and not + // allowed fast, since the current conn shouldn't already be included. It's a very specific + // circumstance, and if it triggers I will fix it. + if ret < 0 { + panic(ret) + } return ret } ml := multiless.New() -- 2.48.1