Trying to check / simplify / improve math
This commit is contained in:
parent
c5b21992e6
commit
3e2fac81b1
3 changed files with 61 additions and 73 deletions
|
|
@ -43,7 +43,7 @@ fn compute_chunk_status(lengths: &Lengths, needed_pieces: &BF) -> anyhow::Result
|
|||
.with_context(|| format!("error getting range {range:?} from needed_pieces"))?
|
||||
.iter_zeros()
|
||||
{
|
||||
let offset = piece_index * lengths.default_max_chunks_per_piece() as usize;
|
||||
let offset = piece_index * lengths.default_chunks_per_piece() as usize;
|
||||
let chunks_per_piece = lengths
|
||||
.chunks_per_piece(lengths.try_validate_piece_index(piece_index as u32)?)
|
||||
as usize;
|
||||
|
|
|
|||
|
|
@ -989,6 +989,8 @@ impl PeerHandler {
|
|||
);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: we don't need chunk info to send data. We can just read the file.
|
||||
let chunk_info = match self.state.lengths.chunk_info_from_received_data(
|
||||
piece_index,
|
||||
request.begin,
|
||||
|
|
@ -1003,6 +1005,8 @@ impl PeerHandler {
|
|||
}
|
||||
};
|
||||
|
||||
// TODO: we only need to check if we have the piece verified. We shouldn't be
|
||||
// sending unvalidated chunks.
|
||||
if !self
|
||||
.state
|
||||
.lock_read("is_chunk_ready_to_upload")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue