mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
(libT) increment the announced downloadCount only when the piece becomes complete.
This commit is contained in:
parent
6d8080bcf4
commit
8a33a1b315
1 changed files with 16 additions and 11 deletions
|
@ -1670,16 +1670,23 @@ cancelAllRequestsForBlock (tr_swarm * s,
|
||||||
void
|
void
|
||||||
tr_peerMgrPieceCompleted (tr_torrent * tor, tr_piece_index_t p)
|
tr_peerMgrPieceCompleted (tr_torrent * tor, tr_piece_index_t p)
|
||||||
{
|
{
|
||||||
int i;
|
bool pieceCameFromPeers = false;
|
||||||
int peerCount;
|
tr_swarm * const s = tor->swarm;
|
||||||
tr_peer ** peers;
|
const tr_peer ** peer = (const tr_peer **) tr_ptrArrayBase (&s->peers);
|
||||||
tr_swarm * s = tor->swarm;
|
const tr_peer ** const pend = peer + tr_ptrArraySize (&s->peers);
|
||||||
|
|
||||||
/* notify the peers that we now have this piece */
|
/* walk through our peers */
|
||||||
peerCount = tr_ptrArraySize (&s->peers);
|
for ( ; peer!=pend; ++peer)
|
||||||
peers = (tr_peer**) tr_ptrArrayBase (&s->peers);
|
{
|
||||||
for (i=0; i<peerCount; ++i)
|
/* notify the peer that we now have this piece */
|
||||||
tr_peerMsgsHave (peers[i]->msgs, p);
|
tr_peerMsgsHave ((*peer)->msgs, p);
|
||||||
|
|
||||||
|
if (!pieceCameFromPeers)
|
||||||
|
pieceCameFromPeers = tr_bitfieldHas (&(*peer)->blame, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pieceCameFromPeers) /* webseed downloads don't belong in announce totals */
|
||||||
|
tr_announcerAddBytes (tor, TR_ANN_DOWN, tr_torPieceCountBytes (tor, p));
|
||||||
|
|
||||||
/* bookkeeping */
|
/* bookkeeping */
|
||||||
pieceListRemovePiece (s, p);
|
pieceListRemovePiece (s, p);
|
||||||
|
@ -1793,8 +1800,6 @@ peerCallbackFunc (tr_peer * peer, const tr_peer_event * e, void * vs)
|
||||||
tr_torrent * tor = s->tor;
|
tr_torrent * tor = s->tor;
|
||||||
const tr_piece_index_t p = e->pieceIndex;
|
const tr_piece_index_t p = e->pieceIndex;
|
||||||
const tr_block_index_t block = _tr_block (tor, p, e->offset);
|
const tr_block_index_t block = _tr_block (tor, p, e->offset);
|
||||||
if (peer->msgs != NULL) /* webseed downloads don't belong in announce totals */
|
|
||||||
tr_announcerAddBytes (tor, TR_ANN_DOWN, tr_torPieceCountBytes (tor, p));
|
|
||||||
cancelAllRequestsForBlock (s, block, peer);
|
cancelAllRequestsForBlock (s, block, peer);
|
||||||
tr_historyAdd (&peer->blocksSentToClient, tr_time(), 1);
|
tr_historyAdd (&peer->blocksSentToClient, tr_time(), 1);
|
||||||
pieceListResortPiece (s, pieceListLookup (s, p));
|
pieceListResortPiece (s, pieceListLookup (s, p));
|
||||||
|
|
Loading…
Reference in a new issue