fix: count webseeds when calculating piece replication (#7028)

This commit is contained in:
Yat Ho 2024-10-24 09:49:01 +08:00 committed by GitHub
parent d8adecbfb5
commit 3ec271fe5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -949,11 +949,12 @@ size_t tr_swarm::WishlistMediator::count_missing_blocks(tr_piece_index_t piece)
size_t tr_swarm::WishlistMediator::count_piece_replication(tr_piece_index_t piece) const
{
return std::accumulate(
std::begin(swarm_.peers),
std::end(swarm_.peers),
size_t{},
[piece](size_t acc, tr_peer* peer) { return acc + (peer->has_piece(piece) ? 1U : 0U); });
auto const op = [piece](size_t acc, auto const& peer)
{
return acc + (peer->has_piece(piece) ? 1U : 0U);
};
return std::accumulate(std::begin(swarm_.peers), std::end(swarm_.peers), size_t{}, op) +
std::accumulate(std::begin(swarm_.webseeds), std::end(swarm_.webseeds), size_t{}, op);
}
tr_block_span_t tr_swarm::WishlistMediator::block_span(tr_piece_index_t piece) const