This commit is contained in:
Igor Katson 2025-01-30 11:24:43 +00:00
parent 62d5288398
commit 3e6c2eae79
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
5 changed files with 36 additions and 24 deletions

View file

@ -1253,10 +1253,7 @@ impl PeerHandler {
///
/// If this returns, an existing in-flight piece was marked to be ours.
fn try_steal_old_slow_piece(&self, threshold: f64) -> Option<ValidPieceIndex> {
let my_avg_time = match self.counters.average_piece_download_time() {
Some(t) => t,
None => return None,
};
let my_avg_time = self.counters.average_piece_download_time()?;
let (stolen_idx, from_peer) = {
let mut g = self.state.lock_write("try_steal_old_slow_piece");

View file

@ -263,8 +263,6 @@ impl LivePeerState {
}
pub fn has_full_torrent(&self, total_pieces: usize) -> bool {
self.bitfield
.get(0..total_pieces)
.map_or(false, |s| s.all())
self.bitfield.get(0..total_pieces).is_some_and(|s| s.all())
}
}