disable SWIFT on private trackers, because they are typically ratio-based sites where you *want* to upload as much as possible to deadbeats

This commit is contained in:
Charles Kerr 2007-11-26 04:05:12 +00:00
parent 63cb8506ca
commit e354b82452
3 changed files with 24 additions and 2 deletions

View File

@ -43,6 +43,8 @@ typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t;
#define FALSE 0
#endif
int tr_torrentIsPrivate( const tr_torrent * );
void tr_torrentRecheckCompleteness( tr_torrent * );
int tr_trackerInfoInit( struct tr_tracker_info * info,

View File

@ -1442,12 +1442,23 @@ sendKeepalive( tr_peermsgs * msgs )
***
**/
static int
isSwiftEnabled( const tr_peermsgs * msgs )
{
/* rationale: SWIFT is good for getting rid of deadbeats, but most
* private trackers have ratios where you _want_ to feed deadbeats
* as much as possible. So we disable SWIFT on private torrents */
return SWIFT_ENABLED
&& !tr_torrentIsSeed( msgs->torrent )
&& !tr_torrentIsPrivate( msgs->torrent );
}
static size_t
getUploadMax( const tr_peermsgs * msgs )
{
static const size_t maxval = ~0;
const tr_torrent * tor = msgs->torrent;
const int useSwift = SWIFT_ENABLED && !tr_torrentIsSeed( msgs->torrent );
const int useSwift = isSwiftEnabled( msgs );
const size_t swiftLeft = msgs->info->credit;
size_t speedLeft;
size_t bufLeft;

View File

@ -641,10 +641,19 @@ tr_torrentChangeMyPort( tr_torrent * tor )
tr_trackerChangeMyPort( tor->tracker );
}
int
tr_torrentIsPrivate( const tr_torrent * tor )
{
return tor
&& tor->info.isPrivate;
}
int
tr_torrentIsPexEnabled( const tr_torrent * tor )
{
return !tor->info.isPrivate && !tor->pexDisabled;
return tor
&& !tr_torrentIsPrivate( tor )
&& !tor->pexDisabled;
}
void