Skip to content

Commit

Permalink
Avoid division by zero by skipping empty list of peers pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Oct 17, 2024
1 parent 08b4e10 commit d3a8ef0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/subspace-networking/src/utils/piece_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ where
break;
};

if connected_peers.is_empty() || pieces_to_download.is_empty() {
break;
}

let num_pieces = pieces_to_download.len();
let step = num_pieces / connected_peers.len().min(num_pieces);

Expand Down

0 comments on commit d3a8ef0

Please sign in to comment.