Speed computation now better fits torrent with large pieces
This commit is contained in:
parent
d0757d41c5
commit
3b8c4e053f
1 changed files with 7 additions and 3 deletions
|
|
@ -247,10 +247,14 @@ impl TorrentManager {
|
||||||
let state = mgr.state.clone();
|
let state = mgr.state.clone();
|
||||||
async move {
|
async move {
|
||||||
loop {
|
loop {
|
||||||
let downloaded = state.stats_snapshot().downloaded_and_checked_bytes;
|
let stats = state.stats_snapshot();
|
||||||
|
let fetched = state.stats_snapshot().fetched_bytes;
|
||||||
let needed = state.initially_needed();
|
let needed = state.initially_needed();
|
||||||
let remaining = needed - downloaded;
|
// fetched can be too high in theory, so for safety make sure that it doesn't wrap around u64.
|
||||||
estimator.add_snapshot(downloaded, remaining, Instant::now());
|
let remaining = needed
|
||||||
|
.wrapping_sub(fetched)
|
||||||
|
.min(needed - stats.downloaded_and_checked_bytes);
|
||||||
|
estimator.add_snapshot(fetched, remaining, Instant::now());
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue