From: Matt Joiner Date: Mon, 25 Oct 2021 09:53:39 +0000 (+1100) Subject: Fix iter pending chunk request offsets X-Git-Tag: v1.34.0^2~5 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ccf57798a2e9da4c6c37735e1d96bea0f30217cd;p=btrtrc.git Fix iter pending chunk request offsets --- diff --git a/requesting.go b/requesting.go index 74d1d682..669b0d2a 100644 --- a/requesting.go +++ b/requesting.go @@ -214,6 +214,7 @@ func (p *Peer) getDesiredRequestState() (desired requestState) { } allowedFast := p.peerAllowedFast.ContainsInt(pieceIndex) rsp.IterPendingChunks.Iter(func(ci request_strategy.ChunkIndex) { + r := p.t.pieceRequestIndexOffset(pieceIndex) + ci if !allowedFast { // We must signal interest to request this desired.Interested = true @@ -221,14 +222,12 @@ func (p *Peer) getDesiredRequestState() (desired requestState) { // have made the request previously (presumably while unchoked), and haven't had // the peer respond yet (and the request was retained because we are using the // fast extension). - if p.peerChoking && !p.actualRequestState.Requests.Contains(ci) { + if p.peerChoking && !p.actualRequestState.Requests.Contains(r) { // We can't request this right now. return } } - requestHeap.requestIndexes = append( - requestHeap.requestIndexes, - p.t.pieceRequestIndexOffset(pieceIndex)+ci) + requestHeap.requestIndexes = append(requestHeap.requestIndexes, r) }) }, )