1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

follow BT `best practices' more closely w.r.t. choosing which pieces to download

This commit is contained in:
Charles Kerr 2007-10-01 14:24:22 +00:00
parent 5f41c28cbe
commit f7e3f85e50

View file

@ -482,6 +482,7 @@ struct tr_refill_piece
uint32_t piece; uint32_t piece;
uint32_t peerCount; uint32_t peerCount;
uint32_t fastAllowed; uint32_t fastAllowed;
uint32_t random;
}; };
static int static int
@ -502,8 +503,8 @@ compareRefillPiece (const void * aIn, const void * bIn)
if (a->fastAllowed != b->fastAllowed) if (a->fastAllowed != b->fastAllowed)
return a->fastAllowed < b->fastAllowed ? -1 : 1; return a->fastAllowed < b->fastAllowed ? -1 : 1;
/* otherwise go with the earlier piece */ /* otherwise go with our random seed */
return a->piece - b->piece; return tr_compareUint32( a->random, b->random );
} }
static int static int
@ -555,6 +556,7 @@ getPreferredPieces( Torrent * t,
setme->priority = inf->pieces[piece].priority; setme->priority = inf->pieces[piece].priority;
setme->peerCount = 0; setme->peerCount = 0;
setme->fastAllowed = 0; setme->fastAllowed = 0;
setme->random = tr_rand( UINT32_MAX );
/* FIXME */ /* FIXME */
// setme->fastAllowed = tr_bitfieldHas( t->tor->allowedList, i); // setme->fastAllowed = tr_bitfieldHas( t->tor->allowedList, i);