From c6fb0535d4f6148acdc262fe91390f76e630af68 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 16 Sep 2021 17:10:07 +1000 Subject: [PATCH] requesting: Remove some obsoleted condition checks These shouldn't be necessary since peers were pruned for the ability to allocate chunks to the current piece. --- request-strategy/order.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/request-strategy/order.go b/request-strategy/order.go index 9b81a948..8b4b6799 100644 --- a/request-strategy/order.go +++ b/request-strategy/order.go @@ -311,9 +311,7 @@ func allocatePendingChunks(p requestablePiece, peers []*requestsPeer) { } defer func() { for _, peer := range peersForPiece { - if peer.canRequestPiece(p.index) { - peer.requestablePiecesRemaining-- - } + peer.requestablePiecesRemaining-- } peersForPiecesPool.Put(peersForPiece) }() @@ -338,9 +336,6 @@ func allocatePendingChunks(p requestablePiece, peers []*requestsPeer) { if !peer.canFitRequest() { continue } - if !peer.canRequestPiece(p.index) { - continue - } preallocated[spec] = append(preallocated[spec], peer) peer.addNextRequest(req) } @@ -357,9 +352,6 @@ func allocatePendingChunks(p requestablePiece, peers []*requestsPeer) { if !peer.canFitRequest() { continue } - if !peer.HasPiece(p.index) { - continue - } if !peer.pieceAllowedFastOrDefault(p.index) { // TODO: Verify that's okay to stay uninterested if we request allowed fast pieces. peer.nextState.Interested = true @@ -386,9 +378,6 @@ chunk: if !peer.canFitRequest() { continue } - if !peer.HasPiece(p.index) { - continue - } if !peer.pieceAllowedFastOrDefault(p.index) { // TODO: Verify that's okay to stay uninterested if we request allowed fast pieces. peer.nextState.Interested = true -- 2.48.1