mirror of
https://github.com/transmission/transmission
synced 2025-03-16 00:39:34 +00:00
update a couple of the tr_stat fields based on feedback from BMW
This commit is contained in:
parent
67ea41051f
commit
f12ac60d0a
5 changed files with 24 additions and 29 deletions
|
@ -52,7 +52,7 @@ getProgressString( const tr_info * info, const tr_stat * torStat )
|
|||
%3$.2f%% is a percentage of the two */
|
||||
_("%1$s of %2$s (%3$.2f%%)"),
|
||||
tr_strlsize( buf1, haveTotal, sizeof(buf1) ),
|
||||
tr_strlsize( buf2, torStat->desiredSize, sizeof(buf2) ),
|
||||
tr_strlsize( buf2, torStat->sizeWhenDone, sizeof(buf2) ),
|
||||
torStat->percentDone * 100.0 );
|
||||
else if( !isSeed )
|
||||
str = g_strdup_printf(
|
||||
|
|
|
@ -1417,26 +1417,25 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
|
|||
managerUnlock( (tr_peerMgr*)manager );
|
||||
}
|
||||
|
||||
/* Returns the pieces that we and/or a connected peer has */
|
||||
/* Returns the pieces that are available from peers */
|
||||
tr_bitfield*
|
||||
tr_peerMgrGetAvailable( const tr_peerMgr * manager,
|
||||
const uint8_t * torrentHash )
|
||||
{
|
||||
int i, size;
|
||||
const Torrent * t;
|
||||
const tr_peer ** peers;
|
||||
Torrent * t;
|
||||
tr_peer ** peers;
|
||||
tr_bitfield * pieces;
|
||||
|
||||
managerLock( (tr_peerMgr*)manager );
|
||||
|
||||
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
|
||||
peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &size );
|
||||
pieces = tr_bitfieldDup( tr_cpPieceBitfield( t->tor->completion ) );
|
||||
pieces = tr_bitfieldNew( t->tor->info.pieceCount );
|
||||
peers = getConnectedPeers( t, &size );
|
||||
for( i=0; i<size; ++i )
|
||||
if( peers[i]->io != NULL )
|
||||
tr_bitfieldOr( pieces, peers[i]->have );
|
||||
tr_bitfieldOr( pieces, peers[i]->have );
|
||||
|
||||
managerUnlock( (tr_peerMgr*)manager );
|
||||
tr_free( peers );
|
||||
return pieces;
|
||||
}
|
||||
|
||||
|
|
|
@ -638,28 +638,24 @@ tr_torrentStat( tr_torrent * tor )
|
|||
|
||||
{
|
||||
tr_piece_index_t i;
|
||||
tr_bitfield * availablePieces = tr_peerMgrGetAvailable( tor->handle->peerMgr,
|
||||
tor->info.hash );
|
||||
s->desiredSize = 0;
|
||||
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 ) {
|
||||
const uint64_t byteCount = tr_torPieceCountBytes( tor, i );
|
||||
s->desiredSize += byteCount;
|
||||
if( tr_bitfieldHas( availablePieces, i ) )
|
||||
s->desiredAvailable += byteCount;
|
||||
s->sizeWhenDone += tor->info.pieceSize;
|
||||
if( tr_bitfieldHas( peerPieces, i ) )
|
||||
s->desiredAvailable += tr_cpMissingBlocksInPiece( tor->completion, i );
|
||||
}
|
||||
}
|
||||
|
||||
/* "availablePieces" can miss our unverified blocks... */
|
||||
if( s->desiredAvailable < s->haveValid + s->haveUnchecked )
|
||||
s->desiredAvailable = s->haveValid + s->haveUnchecked;
|
||||
|
||||
tr_bitfieldFree( availablePieces );
|
||||
s->desiredAvailable *= tor->blockSize;
|
||||
tr_bitfieldFree( peerPieces );
|
||||
}
|
||||
|
||||
if( s->desiredSize > s->desiredAvailable )
|
||||
if( s->leftUntilDone > s->desiredAvailable )
|
||||
s->eta = TR_ETA_NOT_AVAIL;
|
||||
else if( s->rateDownload < 0.1 )
|
||||
s->eta = TR_ETA_UNKNOWN;
|
||||
|
|
|
@ -895,13 +895,13 @@ struct tr_stat
|
|||
* moved to `corrupt' or `haveValid'. */
|
||||
uint64_t haveUnchecked;
|
||||
|
||||
/* Byte count of all the non-DND piece data that either we already have,
|
||||
* or that a peer we're connected to has. [0...desiredSize] */
|
||||
uint64_t desiredAvailable;
|
||||
/* 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, whether we currently
|
||||
* have it nor not. [0...tr_info.totalSize] */
|
||||
uint64_t desiredSize;
|
||||
/* 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;
|
||||
|
||||
|
|
|
@ -889,7 +889,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (float) notAvailableDesired
|
||||
{
|
||||
return (float)(fStat->desiredSize - fStat->desiredAvailable) / [self size];
|
||||
return (float)(fStat->sizeWhenDone - fStat->desiredAvailable) / [self size];
|
||||
}
|
||||
|
||||
- (BOOL) isActive
|
||||
|
|
Loading…
Add table
Reference in a new issue