Changeset 4283


Ignore:
Timestamp:
Dec 22, 2007, 4:11:15 PM (14 years ago)
Author:
charles
Message:

save per-torrent peer limits in the fastresume file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.c

    r4267 r4283  
    107107    /* pex flag
    108108     * 't' if pex is enabled, 'f' if disabled */
    109     FR_ID_PEX = 13
     109    FR_ID_PEX = 13,
     110
     111    /* max connected peers -- uint16_t */
     112    FR_ID_MAX_PEERS = 14,
     113
     114    /* max unchoked peers -- uint8_t */
     115    FR_ID_MAX_UNCHOKED = 15
    110116};
    111117
     
    310316    fastResumeWriteData( FR_ID_CORRUPT, &total, 8, 1, file );
    311317
     318    fastResumeWriteData( FR_ID_MAX_PEERS,
     319                         &tor->maxConnectedPeers,
     320                         sizeof(uint16_t), 1, file );
     321
     322    fastResumeWriteData( FR_ID_MAX_UNCHOKED,
     323                         &tor->maxUnchokedPeers,
     324                         sizeof(uint8_t), 1, file );
     325
    312326    if( !tor->info.isPrivate )
    313327    {
     
    384398    readBytes( &tor->corruptPrev, &buf, sizeof(uint64_t) );
    385399    return TR_FR_CORRUPT;
     400}
     401
     402static uint64_t
     403parseConnections( tr_torrent * tor, const uint8_t * buf, uint32_t len )
     404{
     405    if( len != sizeof(uint16_t) )
     406        return 0;
     407    readBytes( &tor->maxConnectedPeers, &buf, sizeof(uint16_t) );
     408    return TR_FR_MAX_PEERS;
     409}
     410
     411static uint64_t
     412parseUnchoked( tr_torrent * tor, const uint8_t * buf, uint32_t len )
     413{
     414    if( len != sizeof(uint8_t) )
     415        return 0;
     416    readBytes( &tor->maxUnchokedPeers, &buf, sizeof(uint8_t) );
     417    return TR_FR_MAX_UNCHOKED;
    386418}
    387419
     
    575607        if( fieldsToLoad & internalIdToPublicBitfield( id ) ) switch( id )
    576608        {
    577             case FR_ID_DOWNLOADED:  ret |= parseDownloaded( tor, buf, len ); break;
    578             case FR_ID_UPLOADED:    ret |= parseUploaded( tor, buf, len ); break;
    579             case FR_ID_PROGRESS:    ret |= parseProgress( tor, buf, len, uncheckedPieces ); break;
    580             case FR_ID_PRIORITY:    ret |= parsePriorities( tor, buf, len ); break;
    581             case FR_ID_SPEED:       ret |= parseSpeedLimit( tor, buf, len ); break;
    582             case FR_ID_RUN:         ret |= parseRun( tor, buf, len ); break;
    583             case FR_ID_CORRUPT:     ret |= parseCorrupt( tor, buf, len ); break;
    584             case FR_ID_PEERS:       ret |= parsePeers( tor, buf, len ); break;
     609            case FR_ID_DOWNLOADED:   ret |= parseDownloaded( tor, buf, len ); break;
     610            case FR_ID_UPLOADED:     ret |= parseUploaded( tor, buf, len ); break;
     611            case FR_ID_PROGRESS:     ret |= parseProgress( tor, buf, len, uncheckedPieces ); break;
     612            case FR_ID_PRIORITY:     ret |= parsePriorities( tor, buf, len ); break;
     613            case FR_ID_SPEED:        ret |= parseSpeedLimit( tor, buf, len ); break;
     614            case FR_ID_RUN:          ret |= parseRun( tor, buf, len ); break;
     615            case FR_ID_CORRUPT:      ret |= parseCorrupt( tor, buf, len ); break;
     616            case FR_ID_PEERS:        ret |= parsePeers( tor, buf, len ); break;
     617            case FR_ID_MAX_PEERS:    ret |= parseConnections( tor, buf, len ); break;
     618            case FR_ID_MAX_UNCHOKED: ret |= parseUnchoked( tor, buf, len ); break;
    585619            case FR_ID_PEX:         ret |= parsePex( tor, buf, len ); break;
    586620            case FR_ID_DESTINATION: ret |= parseDestination( tor, buf, len ); break;
Note: See TracChangeset for help on using the changeset viewer.