]> Sergey Matveev's repositories - btrtrc.git/commitdiff
requesting: Remove some obsoleted condition checks
authorMatt Joiner <anacrolix@gmail.com>
Thu, 16 Sep 2021 07:10:07 +0000 (17:10 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 18 Sep 2021 02:53:22 +0000 (12:53 +1000)
These shouldn't be necessary since peers were pruned for the ability to allocate chunks to the current piece.

request-strategy/order.go

index 9b81a94858fcfed2c7b6133f83ce8a1807e4ea6d..8b4b67998d691fc506410d9fad4d17af4c26faa3 100644 (file)
@@ -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