Ignore:
Timestamp:
Nov 9, 2006, 4:45:14 AM (16 years ago)
Author:
titer
Message:

Saves a list of peers when you pause a torrent, and tries to reconnect to them next time you resume it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.h

    r931 r1060  
    5151/* number of bytes uploaded */
    5252#define FR_ID_UPLOADED          0x03
     53/* IPs and ports of connectable peers */
     54#define FR_ID_PEERS             0x04
    5355
    5456/* macros for the length of various pieces of the progress data */
     
    127129    uint8_t * buf;
    128130    uint64_t  total;
     131    int       size;
    129132
    130133    buf = malloc( FR_PROGRESS_LEN( tor ) );
     
    167170    total = tor->uploadedCur + tor->uploadedPrev;
    168171    fastResumeWriteData( FR_ID_UPLOADED, &total, 8, 1, file );
     172
     173    /* Write IPs and ports of connectable peers, if any */
     174    if( ( size = tr_peerGetConnectable( tor, &buf ) ) > 0 )
     175    {
     176        fastResumeWriteData( FR_ID_PEERS, buf, size, 1, file );
     177        free( buf );
     178    }
    169179
    170180    fclose( file );
     
    359369                break;
    360370
     371            case FR_ID_PEERS:
     372            {
     373                uint8_t * buf = malloc( len );
     374                if( 1 != fread( buf, len, 1, file ) )
     375                {
     376                    free( buf );
     377                    fclose( file );
     378                    return 1;
     379                }
     380                tr_peerAddCompactMany( tor, buf, len );
     381                free( buf );
     382                continue;
     383            }
     384
    361385            default:
    362386                break;
Note: See TracChangeset for help on using the changeset viewer.