Changeset 1064


Ignore:
Timestamp:
Nov 10, 2006, 4:21:46 AM (15 years ago)
Author:
titer
Message:

Adds progress in tr_peer_stat_t

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer.c

    r1060 r1064  
    6464    /* The pieces that the peer has */
    6565    uint8_t      * bitfield;
     66    int            pieceCount;
     67    float          progress;
    6668
    6769    int            goodPcs;
     
    536538
    537539/***********************************************************************
     540 * tr_peerIsDownloading
     541 ***********************************************************************
     542 *
     543 **********************************************************************/
     544float tr_peerProgress( tr_peer_t * peer )
     545{
     546    return peer->progress;
     547}
     548
     549/***********************************************************************
    538550 * tr_peerBitfield
    539551 ***********************************************************************
  • trunk/libtransmission/peer.h

    r1060 r1064  
    4444int         tr_peerIsUploading   ( tr_peer_t * );
    4545int         tr_peerIsDownloading ( tr_peer_t * );
     46float       tr_peerProgress      ( tr_peer_t * );
    4647uint8_t *   tr_peerBitfield      ( tr_peer_t * );
    4748float       tr_peerDownloadRate  ( tr_peer_t * );
  • trunk/libtransmission/peerparse.h

    r931 r1064  
    107107        peer->bitfield = calloc( ( tor->info.pieceCount + 7 ) / 8, 1 );
    108108    }
     109    if( !tr_bitfieldHas( peer->bitfield, piece ) )
     110    {
     111        peer->pieceCount++;
     112        peer->progress = (float) peer->pieceCount / tor->info.pieceCount;
     113    }
    109114    tr_bitfieldAdd( peer->bitfield, piece );
    110115    updateInterest( tor, peer );
     
    120125    tr_info_t * inf = &tor->info;
    121126    int bitfieldSize;
     127    int i;
    122128
    123129    bitfieldSize = ( inf->pieceCount + 7 ) / 8;
     
    152158    }
    153159    memcpy( peer->bitfield, p, bitfieldSize );
     160
     161    peer->pieceCount = 0;
     162    for( i = 0; i < inf->pieceCount; i++ )
     163    {
     164        if( tr_bitfieldHas( peer->bitfield, i ) )
     165        {
     166            peer->pieceCount++;
     167        }
     168    }
     169    peer->progress = (float) peer->pieceCount / inf->pieceCount;
     170
    154171    updateInterest( tor, peer );
    155172
  • trunk/libtransmission/transmission.c

    r1007 r1064  
    592592            peers[i].isDownloading = tr_peerIsDownloading(peer);
    593593            peers[i].isUploading = tr_peerIsUploading(peer);
     594            peers[i].progress = tr_peerProgress(peer);
    594595        }
    595596    }
  • trunk/libtransmission/transmission.h

    r1006 r1064  
    379379    int     isDownloading;
    380380    int     isUploading;
     381    float   progress;
    381382};
    382383
Note: See TracChangeset for help on using the changeset viewer.