minor tr_torrentStat cleanup

This commit is contained in:
Charles Kerr 2008-04-12 15:56:21 +00:00
parent 5d195e00f3
commit fc866f51f3
4 changed files with 23 additions and 19 deletions

View File

@ -302,6 +302,14 @@ tr_cpLeftUntilDone ( const tr_completion * cp )
return cp->doneTotal - cp->doneHave;
}
uint64_t
tr_cpSizeWhenDone( const tr_completion * cp )
{
tr_cpEnsureDoneValid( cp );
return cp->doneTotal;
}
cp_status_t
tr_cpGetStatus ( const tr_completion * cp )
{

View File

@ -40,6 +40,7 @@ uint64_t tr_cpHaveTotal( const tr_completion * );
uint64_t tr_cpHaveValid( const tr_completion * );
uint64_t tr_cpLeftUntilComplete( const tr_completion * );
uint64_t tr_cpLeftUntilDone( const tr_completion * );
uint64_t tr_cpSizeWhenDone( const tr_completion * );
float tr_cpPercentComplete( const tr_completion * );
float tr_cpPercentDone( const tr_completion * );
void tr_cpInvalidateDND ( tr_completion * );

View File

@ -613,6 +613,7 @@ tr_torrentStat( tr_torrent * tor )
s->percentDone = tr_cpPercentDone( tor->completion );
s->leftUntilDone = tr_cpLeftUntilDone( tor->completion );
s->sizeWhenDone = tr_cpSizeWhenDone( tor->completion );
s->recheckProgress =
1.0 - (tr_torrentCountUncheckedPieces( tor ) / (double) tor->info.pieceCount);
@ -640,17 +641,10 @@ tr_torrentStat( tr_torrent * tor )
tr_piece_index_t i;
tr_bitfield * peerPieces = tr_peerMgrGetAvailable( tor->handle->peerMgr,
tor->info.hash );
s->sizeWhenDone = 0;
s->desiredAvailable = 0;
for( i=0; i<tor->info.pieceCount; ++i ) {
if( !tor->info.pieces[i].dnd ) {
s->sizeWhenDone += tor->info.pieceSize;
if( tr_bitfieldHas( peerPieces, i ) )
s->desiredAvailable += tr_cpMissingBlocksInPiece( tor->completion, i );
}
}
for( i=0; i<tor->info.pieceCount; ++i )
if( !tor->info.pieces[i].dnd && tr_bitfieldHas( peerPieces, i ) )
s->desiredAvailable += tr_cpMissingBlocksInPiece( tor->completion, i );
s->desiredAvailable *= tor->blockSize;
tr_bitfieldFree( peerPieces );
}

View File

@ -876,10 +876,19 @@ struct tr_stat
* for more peers. otherwise, the value is zero. */
time_t manualAnnounceTime;
/* Byte count of all the piece data we'll have downloaded when we're done.
* whether or not we have it yet. [0...tr_info.totalSize] */
uint64_t sizeWhenDone;
/* Byte count of how much data is left to be downloaded until
* we're done -- that is, until we've got all the pieces we wanted. */
* we're done -- that is, until we've got all the pieces we wanted.
* [0...tr_info.sizeWhenDone] */
uint64_t leftUntilDone;
/* Byte count of all the piece data we want and don't have yet,
* but that a connected peer does have. [0...leftUntilDone] */
uint64_t desiredAvailable;
/* Byte count of all the corrupt data you've ever downloaded for
* this torrent. If you're on a poisoned torrent, this number can
* grow very large. */
@ -901,14 +910,6 @@ struct tr_stat
* moved to `corrupt' or `haveValid'. */
uint64_t haveUnchecked;
/* Byte count of all the piece data we'll have downloaded when we're done.
* whether or not we have it yet. [0...tr_info.totalSize] */
uint64_t sizeWhenDone;
/* Byte count of all the piece data we want and don't have yet,
* but that a connected peer does have. [0...sizeWhenDone] */
uint64_t desiredAvailable;
float swarmspeed;
#define TR_RATIO_NA -1