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

Adds progress in tr_peer_stat_t

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.