From b1cd6ecccc5bffb7577618c2a516911154e74dc1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 23 Jan 2008 17:06:36 +0000 Subject: [PATCH] remove unused "max unchoked peers" feature. fix obsolete TR_FLAG_SAVE comment. --- libtransmission/fastresume.c | 24 +----------------------- libtransmission/fastresume.h | 3 +-- libtransmission/peer-mgr.c | 5 ++++- libtransmission/torrent-ctor.c | 30 ------------------------------ libtransmission/torrent.c | 13 ------------- libtransmission/torrent.h | 1 - libtransmission/transmission.h | 17 ++--------------- 7 files changed, 8 insertions(+), 85 deletions(-) diff --git a/libtransmission/fastresume.c b/libtransmission/fastresume.c index 407d7af24..c2b953a4b 100644 --- a/libtransmission/fastresume.c +++ b/libtransmission/fastresume.c @@ -111,10 +111,7 @@ enum FR_ID_PEX = 13, /* max connected peers -- uint16_t */ - FR_ID_MAX_PEERS = 14, - - /* max unchoked peers -- uint8_t */ - FR_ID_MAX_UNCHOKED = 15 + FR_ID_MAX_PEERS = 14 }; @@ -315,10 +312,6 @@ tr_fastResumeSave( const tr_torrent * tor ) &tor->maxConnectedPeers, sizeof(uint16_t), 1, file ); - fastResumeWriteData( FR_ID_MAX_UNCHOKED, - &tor->maxUnchokedPeers, - sizeof(uint8_t), 1, file ); - if( !tor->info.isPrivate ) { tr_pex * pex; @@ -356,7 +349,6 @@ internalIdToPublicBitfield( uint8_t id ) case FR_ID_PEERS: ret = TR_FR_PEERS; break; case FR_ID_DESTINATION: ret = TR_FR_DESTINATION; break; case FR_ID_MAX_PEERS: ret = TR_FR_MAX_PEERS; break; - case FR_ID_MAX_UNCHOKED: ret = TR_FR_MAX_UNCHOKED; break; } return ret; @@ -405,15 +397,6 @@ parseConnections( tr_torrent * tor, const uint8_t * buf, uint32_t len ) return TR_FR_MAX_PEERS; } -static uint64_t -parseUnchoked( tr_torrent * tor, const uint8_t * buf, uint32_t len ) -{ - if( len != sizeof(uint8_t) ) - return 0; - readBytes( &tor->maxUnchokedPeers, &buf, sizeof(uint8_t) ); - return TR_FR_MAX_UNCHOKED; -} - static uint64_t parseProgress( tr_torrent * tor, const uint8_t * buf, @@ -603,7 +586,6 @@ parseVersion1( tr_torrent * tor, const uint8_t * buf, const uint8_t * end, case FR_ID_CORRUPT: ret |= parseCorrupt( tor, buf, len ); break; case FR_ID_PEERS: ret |= parsePeers( tor, buf, len ); break; case FR_ID_MAX_PEERS: ret |= parseConnections( tor, buf, len ); break; - case FR_ID_MAX_UNCHOKED: ret |= parseUnchoked( tor, buf, len ); break; case FR_ID_DESTINATION: ret |= parseDestination( tor, buf, len ); break; default: tr_dbg( "Skipping unknown resume code %d", (int)id ); break; } @@ -680,10 +662,6 @@ setFromCtor( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor, int mode ) } } - if( fields & TR_FR_MAX_UNCHOKED ) - if( !tr_ctorGetMaxUnchokedPeers( ctor, mode, &tor->maxUnchokedPeers ) ) - ret |= TR_FR_MAX_UNCHOKED; - if( fields & TR_FR_MAX_PEERS ) if( !tr_ctorGetMaxConnectedPeers( ctor, mode, &tor->maxConnectedPeers ) ) ret |= TR_FR_MAX_PEERS; diff --git a/libtransmission/fastresume.h b/libtransmission/fastresume.h index e2860d14b..858ebebe8 100644 --- a/libtransmission/fastresume.h +++ b/libtransmission/fastresume.h @@ -38,8 +38,7 @@ enum TR_FR_SPEEDLIMIT = (1<<6), TR_FR_RUN = (1<<7), TR_FR_DESTINATION = (1<<8), - TR_FR_MAX_PEERS = (1<<9), - TR_FR_MAX_UNCHOKED = (1<<10) + TR_FR_MAX_PEERS = (1<<9) }; /** diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 82f73d34d..26b9ebdfe 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -96,6 +96,9 @@ enum * this throttle is to avoid overloading the router */ MAX_CONNECTIONS_PER_SECOND = 8, + /* number of unchoked peers per torrent */ + MAX_UNCHOKED_PEERS = 12, + /* corresponds to ut_pex's added.f flags */ ADDED_F_ENCRYPTION_FLAG = 1, @@ -1612,7 +1615,7 @@ rechoke( Torrent * t ) * rate to decide which peers to unchoke. */ unchokedInterested = 0; - for( i=0; itor->maxUnchokedPeers; ++i ) { + for( i=0; iisPaused = isPaused ? 1 : 0; } -void -tr_ctorSetMaxUnchokedPeers( tr_ctor * ctor, - tr_ctorMode mode, - uint8_t maxUnchokedPeers) -{ - struct optional_args * args = &ctor->optionalArgs[mode]; - args->isSet_unchoked = 1; - args->maxUnchokedPeers = maxUnchokedPeers; -} - void tr_ctorSetMaxConnectedPeers( tr_ctor * ctor, tr_ctorMode mode, @@ -199,22 +186,6 @@ tr_ctorGetMaxConnectedPeers( const tr_ctor * ctor, return err; } -int -tr_ctorGetMaxUnchokedPeers( const tr_ctor * ctor, - tr_ctorMode mode, - uint8_t * setmeCount ) -{ - int err = 0; - const struct optional_args * args = &ctor->optionalArgs[mode]; - - if( args->isSet_unchoked ) - *setmeCount = args->maxUnchokedPeers; - else - err = 1; - - return err; -} - int tr_ctorGetIsPaused( const tr_ctor * ctor, tr_ctorMode mode, @@ -271,7 +242,6 @@ tr_ctorNew( const tr_handle * handle ) tr_ctor * ctor = tr_new0( struct tr_ctor, 1 ); ctor->handle = handle; tr_ctorSetMaxConnectedPeers( ctor, TR_FALLBACK, DEFAULT_MAX_CONNECTED_PEERS ); - tr_ctorSetMaxUnchokedPeers( ctor, TR_FALLBACK, DEFAULT_MAX_UNCHOKED_PEERS ); tr_ctorSetPaused( ctor, TR_FALLBACK, FALSE ); tr_ctorSetSave( ctor, TRUE ); return ctor; diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 8539d4c90..9aadfde85 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -1256,25 +1256,12 @@ tr_torrentSetMaxConnectedPeers( tr_torrent * tor, tor->maxConnectedPeers = maxConnectedPeers; } -void -tr_torrentSetMaxUnchokedPeers( tr_torrent * tor, - uint8_t maxUnchokedPeers ) -{ - tor->maxUnchokedPeers = maxUnchokedPeers; -} - uint16_t tr_torrentGetMaxConnectedPeers( const tr_torrent * tor ) { return tor->maxConnectedPeers; } -uint8_t -tr_torrentGetMaxUnchokedPeers( const tr_torrent * tor ) -{ - return tor->maxUnchokedPeers; -} - /*** **** ***/ diff --git a/libtransmission/torrent.h b/libtransmission/torrent.h index 9e6925856..37f36797c 100644 --- a/libtransmission/torrent.h +++ b/libtransmission/torrent.h @@ -153,7 +153,6 @@ struct tr_torrent unsigned int statCur : 1; unsigned int isRunning : 1; - uint8_t maxUnchokedPeers; uint16_t maxConnectedPeers; tr_recheck_state recheckState; diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index ee2ad32e2..c6ee241ec 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -261,11 +261,6 @@ void tr_torrentSetMaxConnectedPeers( tr_torrent * tor, uint16_t tr_torrentGetMaxConnectedPeers( const tr_torrent * tor ); -void tr_torrentSetMaxUnchokedPeers( tr_torrent * tor, - uint8_t maxUnchokedPeers ); - -uint8_t tr_torrentGetMaxUnchokedPeers( const tr_torrent * tor ); - void tr_setGlobalPeerLimit( tr_handle * handle, uint16_t maxGlobalPeers ); @@ -381,10 +376,6 @@ void tr_ctorSetMaxConnectedPeers ( tr_ctor * ctor, tr_ctorMode mode, uint16_t maxConnectedPeers ); -void tr_ctorSetMaxUnchokedPeers ( tr_ctor * ctor, - tr_ctorMode mode, - uint8_t maxUnchokedPeers); - void tr_ctorSetDestination ( tr_ctor * ctor, tr_ctorMode mode, const char * directory ); @@ -397,10 +388,6 @@ int tr_ctorGetMaxConnectedPeers ( const tr_ctor * ctor, tr_ctorMode mode, uint16_t * setmeCount ); -int tr_ctorGetMaxUnchokedPeers ( const tr_ctor * ctor, - tr_ctorMode mode, - uint8_t * setmeCount ); - int tr_ctorGetIsPaused ( const tr_ctor * ctor, tr_ctorMode mode, uint8_t * setmeIsPaused ); @@ -586,8 +573,8 @@ void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size ); /*********************************************************************** * tr_torrentRemoveSaved *********************************************************************** - * Removes the saved copy of a torrent file for torrents which the - * TR_FLAG_SAVE flag is set. + * delete's Transmission's copy of the torrent's metadata from + * tr_getTorrentsDirectory(). **********************************************************************/ void tr_torrentRemoveSaved( tr_torrent * );