Remove a spurious complicated function ".mark_chunk_request_cancelled"

This commit is contained in:
Igor Katson 2024-08-19 12:54:56 +01:00
parent 7cda2c9807
commit 02eca15c70
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 1 additions and 20 deletions

View file

@ -222,25 +222,6 @@ impl ChunkTracker {
self.have[id.get() as usize]
}
// None if wrong chunk
// true if did something
// false if didn't do anything
pub fn mark_chunk_request_cancelled(
&mut self,
index: ValidPieceIndex,
_chunk: u32,
) -> Option<bool> {
if *self.have.get(index.get() as usize)? {
return Some(false);
}
// This will trigger the requesters to re-check each chunk in this piece.
let chunk_range = self.lengths.chunk_range(index);
if !self.chunk_status.get(chunk_range)?.all() {
self.queue_pieces.set(index.get() as usize, true);
}
Some(true)
}
pub fn mark_piece_broken_if_not_have(&mut self, index: ValidPieceIndex) {
if self
.have

View file

@ -904,7 +904,7 @@ impl PeerHandler {
req.chunk_index
);
g.get_chunks_mut()?
.mark_chunk_request_cancelled(req.piece_index, req.chunk_index);
.mark_piece_broken_if_not_have(req.piece_index);
}
}
PeerState::NotNeeded => {