diff options
Diffstat (limited to 'src/swarm/blob.rs')
| -rw-r--r-- | src/swarm/blob.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/swarm/blob.rs b/src/swarm/blob.rs index 82586b8..f3494af 100644 --- a/src/swarm/blob.rs +++ b/src/swarm/blob.rs @@ -642,6 +642,7 @@ pub(crate) async fn fetch( doubled.insert(*index); sources[at].in_flight.insert(*index, now); } + state.stats.chunks_doubled(batch.len()); request(state, &sources[at].peer, id, batch, delta).await; } } @@ -665,7 +666,11 @@ pub(crate) async fn fetch( let at = sources.iter().position(|source| source.peer == from); let sent_at = at.and_then(|at| sources[at].in_flight.remove(&index)); let slot = index as usize; - if slot >= total || chunks[slot].is_some() { + if slot >= total { + continue; + } + if chunks[slot].is_some() { + state.stats.chunk_twice(); continue; } let expected = expected_len(&manifest, slot); @@ -687,6 +692,9 @@ pub(crate) async fn fetch( // A peer that delivers may have one more in flight. source.window = (source.window + 1).min(MAX_WINDOW); } + if at.is_none() { + state.stats.chunk_from_dropped(); + } chunks[slot] = Some(data); done += 1; last_progress = Instant::now(); @@ -724,6 +732,9 @@ pub(crate) async fn fetch( .in_flight .retain(|_, sent| now.saturating_duration_since(*sent) < timeout); if source.in_flight.len() < before { + state + .stats + .chunks_timed_out(before - source.in_flight.len()); source.window = 1; debug!(peer = %source.peer, blob = %id, "Blob chunks timed out; asking others"); } |
