Skip to content

Commit

Permalink
Ranges for indices
Browse files Browse the repository at this point in the history
  • Loading branch information
ErakhtinB committed Dec 26, 2024
1 parent d65d680 commit e371974
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/network/impl/synchronizer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,10 @@ namespace kagome::network {
selected_peers.push_back(p_id);
}
} else {
std::vector<uint32_t> indices(active_peers_size);
std::iota(indices.begin(), indices.end(), 0);
auto indices = std::ranges::views::iota(0, number_of_peers_to_add);
std::random_device rd;
std::mt19937 gen(rd());
std::ranges::shuffle(indices.begin(), indices.end(), gen);
std::ranges::shuffle(indices, gen);
for (uint32_t i = 0; i < number_of_peers_to_add; ++i) {
selected_peers.push_back(active_peers[indices[i]]);
}
Expand Down

0 comments on commit e371974

Please sign in to comment.