Changeset 3058
- Timestamp:
- Sep 13, 2007, 4:50:23 PM (15 years ago)
- Location:
- branches/encryption/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/encryption/libtransmission/completion.c
r2987 r3058 34 34 tr_torrent * tor; 35 35 36 /* true if a peer is requesting this block */37 tr_bitfield * blockRequested;38 39 36 /* do we have this block? */ 40 37 tr_bitfield * blockBitfield; … … 59 56 cp->tor = tor; 60 57 cp->blockBitfield = tr_bitfieldNew( tor->blockCount ); 61 cp->blockRequested = tr_bitfieldNew( tor->blockCount );62 58 cp->pieceBitfield = tr_bitfieldNew( tor->info.pieceCount ); 63 59 cp->completeBlocks = tr_new( uint16_t, tor->info.pieceCount ); … … 72 68 tr_free( cp->completeBlocks ); 73 69 tr_bitfieldFree( cp->pieceBitfield ); 74 tr_bitfieldFree( cp->blockRequested );75 70 tr_bitfieldFree( cp->blockBitfield ); 76 71 tr_free( cp ); … … 83 78 tr_bitfieldClear( cp->pieceBitfield ); 84 79 tr_bitfieldClear( cp->blockBitfield ); 85 tr_bitfieldClear( cp->blockRequested );86 80 memset( cp->completeBlocks, 0, sizeof(uint16_t) * tor->info.pieceCount ); 87 81 … … 191 185 } 192 186 193 /* Blocks */194 void tr_cpDownloaderAdd( tr_completion * cp, int block )195 {196 tr_bitfieldAdd( cp->blockRequested, block );197 }198 199 void tr_cpDownloaderRem( tr_completion * cp, int block )200 {201 tr_bitfieldRem( cp->blockRequested, block );202 }203 204 187 int tr_cpBlockIsComplete( const tr_completion * cp, int block ) 205 188 { … … 260 243 } 261 244 262 int263 tr_cpMissingBlocksForPiece( const tr_completion * cp, int piece )264 {265 int i;266 int n;267 const tr_torrent * tor = cp->tor;268 const int start = tr_torPieceFirstBlock(tor,piece);269 const int end = start + tr_torPieceCountBlocks(tor,piece);270 271 n = 0;272 for( i = start; i < end; ++i )273 if( !tr_cpBlockIsComplete( cp, i ) && !tr_bitfieldHas( cp->blockRequested, i ) )274 ++n;275 276 return n;277 }278 279 int tr_cpMissingBlockInPiece( const tr_completion * cp, int piece )280 {281 int i;282 const tr_torrent * tor = cp->tor;283 const int start = tr_torPieceFirstBlock(tor,piece);284 const int end = start + tr_torPieceCountBlocks(tor,piece);285 286 for( i = start; i < end; ++i )287 if( !tr_cpBlockIsComplete( cp, i ) && !tr_bitfieldHas( cp->blockRequested, i ) )288 return i;289 290 return -1;291 }292 293 245 /*** 294 246 **** -
branches/encryption/libtransmission/completion.h
r2941 r3058 50 50 51 51 /* Blocks */ 52 void tr_cpDownloaderAdd( tr_completion *, int block );53 void tr_cpDownloaderRem( tr_completion *, int block );54 52 int tr_cpBlockIsComplete( const tr_completion *, int block ); 55 53 void tr_cpBlockAdd( tr_completion *, int block ); 56 54 void tr_cpBlockBitfieldSet( tr_completion *, struct tr_bitfield * ); 57 55 float tr_cpPercentBlocksInPiece( const tr_completion * cp, int piece ); 58 /* Missing = we don't have it and we are not getting it from any peer yet */59 int tr_cpMissingBlocksForPiece( const tr_completion * cp, int piece );60 int tr_cpMissingBlockInPiece( const tr_completion *, int piece );61 56 62 57 const struct tr_bitfield * tr_cpPieceBitfield( const tr_completion* );
Note: See TracChangeset
for help on using the changeset viewer.