Changeset 10824


Ignore:
Timestamp:
Jun 23, 2010, 4:36:16 AM (12 years ago)
Author:
charles
Message:

(trunk libT) when comparing peer speed to decide which peers to unchoke, use different criteria for seeding, downloading public, and downloading private. Loosely related to #3334.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r10821 r10824  
    26052605}
    26062606
     2607/* get a rate for deciding which peers to choke and unchoke. */
     2608static int
     2609getRate( const tr_torrent * tor, struct peer_atom * atom, uint64_t now )
     2610{
     2611    double KiB_s;
     2612
     2613    if( tr_torrentIsSeed( tor ) )
     2614        KiB_s = tr_peerGetPieceSpeed( atom->peer, now, TR_CLIENT_TO_PEER );
     2615
     2616    /* downloading a private torrent... take upload speed into account
     2617     * because there may only be a small window of opportunity to share */
     2618    else if( tr_torrentIsPrivate( tor ) )
     2619        KiB_s = tr_peerGetPieceSpeed( atom->peer, now, TR_PEER_TO_CLIENT )
     2620              + tr_peerGetPieceSpeed( atom->peer, now, TR_CLIENT_TO_PEER );
     2621
     2622    /* downloading a public torrent */
     2623    else
     2624        KiB_s = tr_peerGetPieceSpeed( atom->peer, now, TR_PEER_TO_CLIENT );
     2625
     2626    /* convert it to bytes per second */
     2627    return (int)( KiB_s * 1024 );
     2628}
     2629
    26072630static void
    26082631rechokeUploads( Torrent * t, const uint64_t now )
     
    26412664            n->isInterested = peer->peerIsInterested;
    26422665            n->isChoked     = peer->peerIsChoked;
    2643             n->rate         = tr_peerGetPieceSpeed( peer, now, TR_CLIENT_TO_PEER ) * 1024;
     2666            n->rate         = getRate( t->tor, atom, now );
    26442667        }
    26452668    }
Note: See TracChangeset for help on using the changeset viewer.