From 3ec271fe5a25f9d0d831fb71971941ce95936964 Mon Sep 17 00:00:00 2001 From: Yat Ho Date: Thu, 24 Oct 2024 09:49:01 +0800 Subject: [PATCH] fix: count webseeds when calculating piece replication (#7028) --- libtransmission/peer-mgr.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libtransmission/peer-mgr.cc b/libtransmission/peer-mgr.cc index 6061a4f2f..9b53ac40c 100644 --- a/libtransmission/peer-mgr.cc +++ b/libtransmission/peer-mgr.cc @@ -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