2009-01-07 06:53:29 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2009-01-07 06:53:29 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2009-01-07 06:53:29 +00:00
|
|
|
* $Id$
|
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-09 20:07:52 +00:00
|
|
|
#include <assert.h>
|
2007-07-29 18:11:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#include "transmission.h"
|
2007-06-18 03:40:41 +00:00
|
|
|
#include "completion.h"
|
2007-12-25 05:37:32 +00:00
|
|
|
#include "torrent.h"
|
2007-07-30 18:04:10 +00:00
|
|
|
#include "utils.h"
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-11-12 22:26:10 +00:00
|
|
|
static void
|
|
|
|
tr_cpReset( tr_completion * cp )
|
|
|
|
{
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_bitfieldClear( &cp->pieceBitfield );
|
|
|
|
tr_bitfieldClear( &cp->blockBitfield );
|
2009-01-06 07:45:15 +00:00
|
|
|
memset( cp->completeBlocks, 0, sizeof( uint16_t ) * cp->tor->info.pieceCount );
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->sizeNow = 0;
|
|
|
|
cp->sizeWhenDoneIsDirty = 1;
|
2008-11-05 04:50:03 +00:00
|
|
|
cp->haveValidIsDirty = 1;
|
2007-11-12 22:26:10 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
tr_completion *
|
2009-01-02 17:01:55 +00:00
|
|
|
tr_cpConstruct( tr_completion * cp, tr_torrent * tor )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2009-01-02 17:01:55 +00:00
|
|
|
cp->tor = tor;
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->completeBlocks = tr_new( uint16_t, tor->info.pieceCount );
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_bitfieldConstruct( &cp->blockBitfield, tor->blockCount );
|
|
|
|
tr_bitfieldConstruct( &cp->pieceBitfield, tor->info.pieceCount );
|
2006-07-16 19:39:23 +00:00
|
|
|
tr_cpReset( cp );
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
2009-01-02 17:01:55 +00:00
|
|
|
tr_completion*
|
|
|
|
tr_cpDestruct( tr_completion * cp )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_free( cp->completeBlocks );
|
|
|
|
tr_bitfieldDestruct( &cp->pieceBitfield );
|
|
|
|
tr_bitfieldDestruct( &cp->blockBitfield );
|
2009-01-02 17:01:55 +00:00
|
|
|
return cp;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_cpInvalidateDND( tr_completion * cp )
|
2008-04-24 15:25:01 +00:00
|
|
|
{
|
|
|
|
cp->sizeWhenDoneIsDirty = 1;
|
|
|
|
}
|
2007-07-28 15:43:34 +00:00
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
uint64_t
|
|
|
|
tr_cpSizeWhenDone( const tr_completion * ccp )
|
2007-07-28 15:43:34 +00:00
|
|
|
{
|
2008-04-24 15:25:01 +00:00
|
|
|
if( ccp->sizeWhenDoneIsDirty )
|
2008-04-03 21:38:32 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_completion * cp = (tr_completion *) ccp; /* mutable */
|
2008-04-26 14:52:05 +00:00
|
|
|
const tr_torrent * tor = cp->tor;
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_info * info = &tor->info;
|
|
|
|
tr_piece_index_t i;
|
|
|
|
uint64_t size = 0;
|
2007-07-28 15:43:34 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0; i < info->pieceCount; ++i )
|
2008-04-26 14:52:05 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
if( !info->pieces[i].dnd )
|
|
|
|
{
|
2008-06-05 16:23:03 +00:00
|
|
|
/* we want the piece... */
|
2008-04-26 14:52:05 +00:00
|
|
|
size += tr_torPieceCountBytes( tor, i );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
else if( tr_cpPieceIsComplete( cp, i ) )
|
|
|
|
{
|
2008-06-05 16:23:03 +00:00
|
|
|
/* we have the piece... */
|
2008-04-26 14:52:05 +00:00
|
|
|
size += tr_torPieceCountBytes( tor, i );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
else if( cp->completeBlocks[i] )
|
|
|
|
{
|
2008-06-05 16:23:03 +00:00
|
|
|
/* we have part of the piece... */
|
2008-04-26 14:52:05 +00:00
|
|
|
const tr_block_index_t b = tr_torPieceFirstBlock( tor, i );
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_block_index_t e = b + tr_torPieceCountBlocks( tor,
|
|
|
|
i );
|
|
|
|
tr_block_index_t j;
|
|
|
|
for( j = b; j < e; ++j )
|
2008-04-26 14:52:05 +00:00
|
|
|
if( tr_cpBlockIsComplete( cp, j ) )
|
|
|
|
size += tr_torBlockCountBytes( tor, j );
|
|
|
|
}
|
|
|
|
}
|
2007-07-28 15:43:34 +00:00
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->sizeWhenDoneLazy = size;
|
|
|
|
cp->sizeWhenDoneIsDirty = 0;
|
2007-07-28 15:43:34 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
assert( ccp->sizeWhenDoneLazy <= ccp->tor->info.totalSize );
|
|
|
|
assert( ccp->sizeWhenDoneLazy >= ccp->sizeNow );
|
|
|
|
return ccp->sizeWhenDoneLazy;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 16:08:20 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_cpPieceAdd( tr_completion * cp,
|
|
|
|
tr_piece_index_t piece )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_torrent * tor = cp->tor;
|
|
|
|
const tr_block_index_t start = tr_torPieceFirstBlock( tor, piece );
|
|
|
|
const tr_block_index_t end = start + tr_torPieceCountBlocks( tor, piece );
|
|
|
|
tr_block_index_t i;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = start; i < end; ++i )
|
2007-07-28 15:43:34 +00:00
|
|
|
tr_cpBlockAdd( cp, i );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 16:08:20 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_cpPieceRem( tr_completion * cp,
|
|
|
|
tr_piece_index_t piece )
|
2007-01-14 12:00:21 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_torrent * tor = cp->tor;
|
2008-04-24 15:25:01 +00:00
|
|
|
const tr_block_index_t start = tr_torPieceFirstBlock( tor, piece );
|
|
|
|
const tr_block_index_t end = start + tr_torPieceCountBlocks( tor, piece );
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_block_index_t block;
|
2007-01-14 12:00:21 +00:00
|
|
|
|
2008-08-01 16:43:22 +00:00
|
|
|
assert( cp );
|
2007-07-24 20:49:47 +00:00
|
|
|
assert( piece < tor->info.pieceCount );
|
2007-07-28 15:43:34 +00:00
|
|
|
assert( start < tor->blockCount );
|
|
|
|
assert( start <= end );
|
|
|
|
assert( end <= tor->blockCount );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( block = start; block < end; ++block )
|
2008-04-24 15:25:01 +00:00
|
|
|
if( tr_cpBlockIsComplete( cp, block ) )
|
|
|
|
cp->sizeNow -= tr_torBlockCountBytes( tor, block );
|
2007-07-24 20:49:47 +00:00
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->sizeWhenDoneIsDirty = 1;
|
2008-11-05 04:50:03 +00:00
|
|
|
cp->haveValidIsDirty = 1;
|
2007-06-18 03:40:41 +00:00
|
|
|
cp->completeBlocks[piece] = 0;
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_bitfieldRemRange ( &cp->blockBitfield, start, end );
|
|
|
|
tr_bitfieldRem( &cp->pieceBitfield, piece );
|
2007-01-14 12:00:21 +00:00
|
|
|
}
|
|
|
|
|
2007-07-28 15:43:34 +00:00
|
|
|
void
|
2009-01-07 02:22:11 +00:00
|
|
|
tr_cpBlockAdd( tr_completion * cp, tr_block_index_t block )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_torrent * tor = cp->tor;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
if( !tr_cpBlockIsComplete( cp, block ) )
|
|
|
|
{
|
2008-03-22 18:10:59 +00:00
|
|
|
const tr_piece_index_t piece = tr_torBlockPiece( tor, block );
|
2008-09-23 19:11:04 +00:00
|
|
|
const int blockSize = tr_torBlockCountBytes( tor,
|
|
|
|
block );
|
2007-07-24 11:50:29 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
++cp->completeBlocks[piece];
|
|
|
|
|
2008-11-05 04:50:03 +00:00
|
|
|
if( tr_cpPieceIsComplete( cp, piece ) )
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_bitfieldAdd( &cp->pieceBitfield, piece );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-12-29 09:51:54 +00:00
|
|
|
tr_bitfieldAdd( &cp->blockBitfield, block );
|
2007-07-28 15:43:34 +00:00
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->sizeNow += blockSize;
|
2007-07-28 15:43:34 +00:00
|
|
|
|
2008-11-05 04:50:03 +00:00
|
|
|
cp->haveValidIsDirty = 1;
|
2008-04-24 15:25:01 +00:00
|
|
|
cp->sizeWhenDoneIsDirty = 1;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* Initialize a completion object from a bitfield indicating which blocks we have */
|
2009-01-07 02:22:11 +00:00
|
|
|
tr_bool
|
2009-01-06 07:45:15 +00:00
|
|
|
tr_cpBlockBitfieldSet( tr_completion * cp, tr_bitfield * blockBitfield )
|
|
|
|
{
|
|
|
|
int success = FALSE;
|
|
|
|
|
|
|
|
assert( cp );
|
|
|
|
assert( blockBitfield );
|
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* The bitfield of block flags is typically loaded from a resume file.
|
|
|
|
Test the bitfield's length in case the resume file somehow got corrupted */
|
2009-01-07 02:22:11 +00:00
|
|
|
if(( success = blockBitfield->byteCount == cp->blockBitfield.byteCount ))
|
2009-01-06 07:45:15 +00:00
|
|
|
{
|
2009-01-07 02:22:11 +00:00
|
|
|
tr_block_index_t b = 0;
|
|
|
|
tr_piece_index_t p = 0;
|
|
|
|
uint32_t pieceBlock = 0;
|
|
|
|
uint32_t completeBlocksInPiece = 0;
|
|
|
|
tr_block_index_t completeBlocksInTorrent = 0;
|
|
|
|
uint32_t blocksInCurrentPiece = tr_torPieceCountBlocks( cp->tor, p );
|
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* start cp with a state where it thinks we have nothing */
|
2009-01-06 07:45:15 +00:00
|
|
|
tr_cpReset( cp );
|
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* init our block bitfield from the one passed in */
|
|
|
|
memcpy( cp->blockBitfield.bits, blockBitfield->bits, blockBitfield->byteCount );
|
|
|
|
|
|
|
|
/* invalidate the fields that are lazy-evaluated */
|
2009-01-07 02:22:11 +00:00
|
|
|
cp->sizeWhenDoneIsDirty = TRUE;
|
|
|
|
cp->haveValidIsDirty = TRUE;
|
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* to set the remaining fields, we walk through every block... */
|
2009-01-07 02:22:11 +00:00
|
|
|
while( b < cp->tor->blockCount )
|
2009-01-06 07:45:15 +00:00
|
|
|
{
|
2009-01-07 02:22:11 +00:00
|
|
|
if( tr_bitfieldHasFast( blockBitfield, b ) )
|
|
|
|
++completeBlocksInPiece;
|
2009-01-06 07:45:15 +00:00
|
|
|
|
2009-01-07 02:22:11 +00:00
|
|
|
++b;
|
|
|
|
++pieceBlock;
|
2009-01-06 07:45:15 +00:00
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* by the time we reach the end of a piece, we have enough info
|
|
|
|
to update that piece's slot in cp.completeBlocks and cp.pieceBitfield */
|
2009-01-07 02:22:11 +00:00
|
|
|
if( pieceBlock == blocksInCurrentPiece )
|
|
|
|
{
|
|
|
|
cp->completeBlocks[p] = completeBlocksInPiece;
|
|
|
|
completeBlocksInTorrent += completeBlocksInPiece;
|
|
|
|
if( completeBlocksInPiece == blocksInCurrentPiece )
|
|
|
|
tr_bitfieldAdd( &cp->pieceBitfield, p );
|
2009-01-06 07:45:15 +00:00
|
|
|
|
2009-01-09 17:55:48 +00:00
|
|
|
/* reset the per-piece counters because we're starting on a new piece now */
|
2009-01-07 02:22:11 +00:00
|
|
|
++p;
|
|
|
|
completeBlocksInPiece = 0;
|
|
|
|
pieceBlock = 0;
|
|
|
|
blocksInCurrentPiece = tr_torPieceCountBlocks( cp->tor, p );
|
|
|
|
}
|
2009-01-06 07:45:15 +00:00
|
|
|
}
|
|
|
|
|
2009-01-07 02:22:11 +00:00
|
|
|
/* update sizeNow */
|
|
|
|
cp->sizeNow = completeBlocksInTorrent;
|
|
|
|
cp->sizeNow *= tr_torBlockCountBytes( cp->tor, 0 );
|
|
|
|
if( tr_bitfieldHasFast( &cp->blockBitfield, cp->tor->blockCount-1 ) ) {
|
2009-01-09 17:55:48 +00:00
|
|
|
/* the last block is usually smaller than the other blocks,
|
|
|
|
so handle that special case or cp->sizeNow might be too large */
|
2009-01-07 02:22:11 +00:00
|
|
|
cp->sizeNow -= tr_torBlockCountBytes( cp->tor, 0 );
|
|
|
|
cp->sizeNow += tr_torBlockCountBytes( cp->tor, cp->tor->blockCount-1 );
|
|
|
|
}
|
2009-01-06 07:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2008-10-20 17:54:56 +00:00
|
|
|
tr_completeness
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_cpGetStatus( const tr_completion * cp )
|
2007-07-28 15:43:34 +00:00
|
|
|
{
|
2008-11-30 01:52:45 +00:00
|
|
|
if( cp->sizeNow == cp->tor->info.totalSize ) return TR_SEED;
|
|
|
|
if( cp->sizeNow == tr_cpSizeWhenDone( cp ) ) return TR_PARTIAL_SEED;
|
|
|
|
return TR_LEECH;
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-05 04:50:03 +00:00
|
|
|
static uint64_t
|
|
|
|
calculateHaveValid( const tr_completion * ccp )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2008-11-03 17:01:08 +00:00
|
|
|
uint64_t b = 0;
|
|
|
|
tr_piece_index_t i;
|
2008-11-05 04:50:03 +00:00
|
|
|
const tr_torrent * tor = ccp->tor;
|
2008-11-03 17:01:08 +00:00
|
|
|
const uint64_t pieceSize = tor->info.pieceSize;
|
|
|
|
const uint64_t lastPieceSize = tor->lastPieceSize;
|
|
|
|
const tr_piece_index_t lastPiece = tor->info.pieceCount - 1;
|
|
|
|
|
|
|
|
for( i=0; i!=lastPiece; ++i )
|
2008-11-05 04:50:03 +00:00
|
|
|
if( tr_cpPieceIsComplete( ccp, i ) )
|
2008-11-03 17:01:08 +00:00
|
|
|
b += pieceSize;
|
|
|
|
|
2008-11-05 04:50:03 +00:00
|
|
|
if( tr_cpPieceIsComplete( ccp, lastPiece ) )
|
2008-11-03 17:01:08 +00:00
|
|
|
b += lastPieceSize;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-11-12 22:26:10 +00:00
|
|
|
return b;
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2008-11-05 04:50:03 +00:00
|
|
|
uint64_t
|
|
|
|
tr_cpHaveValid( const tr_completion * ccp )
|
|
|
|
{
|
|
|
|
if( ccp->haveValidIsDirty )
|
|
|
|
{
|
|
|
|
tr_completion * cp = (tr_completion *) ccp; /* mutable */
|
|
|
|
cp->haveValidLazy = calculateHaveValid( ccp );
|
|
|
|
cp->haveValidIsDirty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ccp->haveValidLazy;
|
|
|
|
}
|
|
|
|
|
2008-04-24 15:25:01 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_cpGetAmountDone( const tr_completion * cp,
|
|
|
|
float * tab,
|
|
|
|
int tabCount )
|
2008-04-24 15:25:01 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i;
|
2008-06-09 23:58:31 +00:00
|
|
|
const tr_torrent * tor = cp->tor;
|
2008-09-23 19:11:04 +00:00
|
|
|
const float interval = tor->info.pieceCount / (float)tabCount;
|
2009-01-02 17:01:55 +00:00
|
|
|
const int isSeed = tr_cpGetStatus( cp ) == TR_SEED;
|
2008-06-09 23:58:31 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0; i < tabCount; ++i )
|
2008-06-09 23:58:31 +00:00
|
|
|
{
|
|
|
|
const tr_piece_index_t piece = i * interval;
|
|
|
|
|
|
|
|
if( tor == NULL )
|
2008-06-10 00:31:06 +00:00
|
|
|
tab[i] = 0.0f;
|
2008-11-30 01:52:45 +00:00
|
|
|
else if( isSeed || tr_cpPieceIsComplete( cp, piece ) )
|
2008-06-10 00:31:06 +00:00
|
|
|
tab[i] = 1.0f;
|
2008-09-23 19:11:04 +00:00
|
|
|
else
|
|
|
|
tab[i] = (float)cp->completeBlocks[piece] /
|
|
|
|
tr_torPieceCountBlocks( tor, piece );
|
2008-04-24 15:25:01 +00:00
|
|
|
}
|
2007-09-26 01:55:04 +00:00
|
|
|
}
|
2009-01-02 17:01:55 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
tr_cpMissingBlocksInPiece( const tr_completion * cp, tr_piece_index_t piece )
|
|
|
|
{
|
|
|
|
return tr_torPieceCountBlocks( cp->tor, piece ) - cp->completeBlocks[piece];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-07 02:22:11 +00:00
|
|
|
tr_bool
|
2009-01-02 17:01:55 +00:00
|
|
|
tr_cpPieceIsComplete( const tr_completion * cp, tr_piece_index_t piece )
|
|
|
|
{
|
|
|
|
return cp->completeBlocks[piece] == tr_torPieceCountBlocks( cp->tor, piece );
|
|
|
|
}
|
2009-01-12 21:59:53 +00:00
|
|
|
|
|
|
|
tr_bool
|
|
|
|
tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t fileIndex )
|
|
|
|
{
|
|
|
|
tr_block_index_t block;
|
|
|
|
|
|
|
|
const tr_torrent * tor = cp->tor;
|
|
|
|
const tr_file * file = &tor->info.files[fileIndex];
|
|
|
|
const tr_block_index_t firstBlock = file->offset / tor->blockSize;
|
2009-01-25 04:22:11 +00:00
|
|
|
const tr_block_index_t lastBlock = file->length ? ( ( file->offset + file->length - 1 ) / tor->blockSize ) : firstBlock;
|
2009-01-12 21:59:53 +00:00
|
|
|
|
2009-01-25 16:14:11 +00:00
|
|
|
tr_assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece,
|
|
|
|
"file->offset %"PRIu64"; file->length %"PRIu64"; "
|
|
|
|
"pieceSize %"PRIu32"; blockSize %"PRIu32"; "
|
|
|
|
"firstBlock %"PRIu64"; lastBlock %"PRIu64,
|
|
|
|
file->offset, file->length,
|
|
|
|
tor->info.pieceSize, tor->blockSize,
|
|
|
|
firstBlock, lastBlock );
|
|
|
|
|
|
|
|
tr_assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece,
|
|
|
|
"file->offset %"PRIu64"; file->length %"PRIu64"; "
|
|
|
|
"pieceSize %"PRIu32"; blockSize %"PRIu32"; "
|
|
|
|
"firstBlock %"PRIu64"; lastBlock %"PRIu64,
|
|
|
|
file->offset, file->length,
|
|
|
|
tor->info.pieceSize, tor->blockSize,
|
|
|
|
firstBlock, lastBlock );
|
2009-01-12 21:59:53 +00:00
|
|
|
|
|
|
|
for( block=firstBlock; block<=lastBlock; ++block )
|
|
|
|
if( !tr_cpBlockIsComplete( cp, block ) )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|