1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-08 21:04:25 +00:00

remove unused "max unchoked peers" feature. fix obsolete TR_FLAG_SAVE comment.

This commit is contained in:
Charles Kerr 2008-01-23 17:06:36 +00:00
parent 5852c78682
commit b1cd6ecccc
7 changed files with 8 additions and 85 deletions

View file

@ -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;

View file

@ -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)
};
/**

View file

@ -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; i<size && unchokedInterested<t->tor->maxUnchokedPeers; ++i ) {
for( i=0; i<size && unchokedInterested<MAX_UNCHOKED_PEERS; ++i ) {
choke[i].doUnchoke = 1;
if( choke[i].isInterested )
++unchokedInterested;

View file

@ -17,18 +17,15 @@
#include "trcompat.h" /* strlcpy */
#include "utils.h"
#define DEFAULT_MAX_UNCHOKED_PEERS 12
#define DEFAULT_MAX_CONNECTED_PEERS 50
struct optional_args
{
unsigned int isSet_paused : 1;
unsigned int isSet_unchoked : 1;
unsigned int isSet_connected : 1;
unsigned int isSet_destination : 1;
unsigned int isPaused : 1;
uint8_t maxUnchokedPeers;
uint16_t maxConnectedPeers;
char destination[MAX_PATH_LENGTH];
};
@ -153,16 +150,6 @@ tr_ctorSetPaused( tr_ctor * ctor,
args->isPaused = 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;

View file

@ -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;
}
/***
****
***/

View file

@ -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;

View file

@ -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 * );