Skip to content

Commit

Permalink
requesting: Filter peers that can't be allocated chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Sep 16, 2021
1 parent aa32c94 commit b757b62
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion request-strategy/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ func (me *peersForPieceSorter) Less(_i, _j int) bool {
func allocatePendingChunks(p requestablePiece, peers []*requestsPeer) {
peersForPiece := makePeersForPiece(len(peers))
for _, peer := range peers {
if !peer.canRequestPiece(p.index) {
continue
}
if !peer.canFitRequest() {
peer.requestablePiecesRemaining--
continue
}
peersForPiece = append(peersForPiece, &peersForPieceRequests{
requestsInPiece: 0,
requestsPeer: peer,
Expand All @@ -317,7 +324,7 @@ func allocatePendingChunks(p requestablePiece, peers []*requestsPeer) {
sortPeersForPiece := func(req *Request) {
peersForPieceSorter.req = req
sort.Sort(&peersForPieceSorter)
//ensureValidSortedPeersForPieceRequests(peersForPieceSorter)
//ensureValidSortedPeersForPieceRequests(&peersForPieceSorter)
}
// Chunks can be preassigned several times, if peers haven't been able to update their "actual"
// with "next" request state before another request strategy run occurs.
Expand Down

0 comments on commit b757b62

Please sign in to comment.