Changeset 7361


Ignore:
Timestamp:
Dec 12, 2008, 2:44:21 AM (12 years ago)
Author:
charles
Message:

(trunk libT) remove a couple of redundant and/or unused fields from struct peer_atom and tr_peermsgs.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r7357 r7361  
    112112    uint8_t     myflags;     /* flags that aren't defined in added_f */
    113113    uint8_t     uploadOnly;  /* UPLOAD_ONLY_ */
    114     uint8_t     partialSeed;
    115114    tr_port     port;
    116115    uint16_t    numFails;
  • trunk/libtransmission/peer-msgs.c

    r7357 r7361  
    294294    int                    outMessagesBatchPeriod;
    295295
    296     tr_peer *              info;
     296    tr_peer *              peer;
    297297
    298298    tr_session *           session;
    299299    tr_torrent *           torrent;
    300     tr_peerIo *            io;
    301300
    302301    tr_publisher_t *       publisher;
     
    308307    struct request_list    clientWillAskFor;
    309308
    310     tr_timer *             pexTimer;
     309    tr_timer             * pexTimer;
     310    tr_pex               * pex;
    311311
    312312    time_t                 clientSentPexAt;
     
    316316    time_t                outMessagesBatchedAt;
    317317
    318     tr_bitfield *         peerAllowedPieces;
    319 
    320318    struct tr_incoming    incoming;
    321 
    322     tr_pex *              pex;
    323319
    324320    /* if the peer supports the Extension Protocol in BEP 10 and
     
    349345                             tr_getLogTimeStr( timestr, sizeof( timestr ) ),
    350346                             msgs->torrent->info.name,
    351                              tr_peerIoGetAddrStr( msgs->io ),
    352                              msgs->info->client );
     347                             tr_peerIoGetAddrStr( msgs->peer->io ),
     348                             msgs->peer->client );
    353349        va_start( args, fmt );
    354350        evbuffer_add_vprintf( buf, fmt, args );
     
    392388protocolSendReject( tr_peermsgs * msgs, const struct peer_request * req )
    393389{
    394     tr_peerIo       * io  = msgs->io;
     390    tr_peerIo       * io  = msgs->peer->io;
    395391    struct evbuffer * out = msgs->outMessages;
    396392
    397     assert( tr_peerIoSupportsFEXT( msgs->io ) );
     393    assert( tr_peerIoSupportsFEXT( msgs->peer->io ) );
    398394
    399395    tr_peerIoWriteUint32( io, out, sizeof( uint8_t ) + 3 * sizeof( uint32_t ) );
     
    411407                     const struct peer_request * req )
    412408{
    413     tr_peerIo       * io  = msgs->io;
     409    tr_peerIo       * io  = msgs->peer->io;
    414410    struct evbuffer * out = msgs->outMessages;
    415411
     
    429425                    const struct peer_request * req )
    430426{
    431     tr_peerIo       * io  = msgs->io;
     427    tr_peerIo       * io  = msgs->peer->io;
    432428    struct evbuffer * out = msgs->outMessages;
    433429
     
    447443                  uint32_t      index )
    448444{
    449     tr_peerIo       * io  = msgs->io;
     445    tr_peerIo       * io  = msgs->peer->io;
    450446    struct evbuffer * out = msgs->outMessages;
    451447
     
    463459protocolSendAllowedFast( tr_peermsgs * msgs, uint32_t pieceIndex )
    464460{
    465     tr_peerIo       * io  = msgs->io;
     461    tr_peerIo       * io  = msgs->peer->io;
    466462    struct evbuffer * out = msgs->outMessages;
    467463
    468     assert( tr_peerIoSupportsFEXT( msgs->io ) );
     464    assert( tr_peerIoSupportsFEXT( msgs->peer->io ) );
    469465
    470466    tr_peerIoWriteUint32( io, out, sizeof(uint8_t) + sizeof(uint32_t) );
     
    481477                   int           choke )
    482478{
    483     tr_peerIo       * io  = msgs->io;
     479    tr_peerIo       * io  = msgs->peer->io;
    484480    struct evbuffer * out = msgs->outMessages;
    485481
     
    495491protocolSendHaveAll( tr_peermsgs * msgs )
    496492{
    497     tr_peerIo       * io  = msgs->io;
     493    tr_peerIo       * io  = msgs->peer->io;
    498494    struct evbuffer * out = msgs->outMessages;
    499495
    500     assert( tr_peerIoSupportsFEXT( msgs->io ) );
     496    assert( tr_peerIoSupportsFEXT( msgs->peer->io ) );
    501497
    502498    tr_peerIoWriteUint32( io, out, sizeof( uint8_t ) );
     
    511507protocolSendHaveNone( tr_peermsgs * msgs )
    512508{
    513     tr_peerIo       * io  = msgs->io;
     509    tr_peerIo       * io  = msgs->peer->io;
    514510    struct evbuffer * out = msgs->outMessages;
    515511
    516     assert( tr_peerIoSupportsFEXT( msgs->io ) );
     512    assert( tr_peerIoSupportsFEXT( msgs->peer->io ) );
    517513
    518514    tr_peerIoWriteUint32( io, out, sizeof( uint8_t ) );
     
    533529publish( tr_peermsgs * msgs, tr_peer_event * e )
    534530{
    535     assert( msgs->info );
    536     assert( msgs->info->msgs == msgs );
    537 
    538     tr_publisherPublish( msgs->publisher, msgs->info, e );
     531    assert( msgs->peer );
     532    assert( msgs->peer->msgs == msgs );
     533
     534    tr_publisherPublish( msgs->publisher, msgs->peer, e );
    539535}
    540536
     
    570566    tr_peer_event e = blankEvent;
    571567    e.eventType = TR_PEER_PEER_PROGRESS;
    572     e.progress = msgs->info->progress;
     568    e.progress = msgs->peer->progress;
    573569    publish( msgs, &e );
    574570}
     
    700696{
    701697#if 0
    702     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
    703     const int peerIsNeedy = msgs->info->progress < 0.10;
     698    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
     699    const int peerIsNeedy = msgs->peer->progress < 0.10;
    704700
    705701    if( fext && peerIsNeedy && !msgs->haveFastSet )
    706702    {
    707703        size_t i;
    708         const struct tr_address * addr = tr_peerIoGetAddress( msgs->io, NULL );
     704        const struct tr_address * addr = tr_peerIoGetAddress( msgs->peer->io, NULL );
    709705        const tr_info * inf = &msgs->torrent->info;
    710706        const size_t numwant = MIN( MAX_FAST_SET_SIZE, inf->pieceCount );
     
    726722
    727723static int
    728 isPieceInteresting( const tr_peermsgs * peer,
     724isPieceInteresting( const tr_peermsgs * msgs,
    729725                    tr_piece_index_t    piece )
    730726{
    731     const tr_torrent * torrent = peer->torrent;
     727    const tr_torrent * torrent = msgs->torrent;
    732728
    733729    return ( !torrent->info.pieces[piece].dnd )                 /* we want it */
    734730          && ( !tr_cpPieceIsComplete( torrent->completion, piece ) ) /* !have */
    735           && ( tr_bitfieldHas( peer->info->have, piece ) );    /* peer has it */
     731          && ( tr_bitfieldHas( msgs->peer->have, piece ) );    /* peer has it */
    736732}
    737733
     
    754750    bitfield = tr_cpPieceBitfield( torrent->completion );
    755751
    756     if( !msgs->info->have )
     752    if( !msgs->peer->have )
    757753        return TRUE;
    758754
    759     assert( bitfield->byteCount == msgs->info->have->byteCount );
     755    assert( bitfield->byteCount == msgs->peer->have->byteCount );
    760756
    761757    for( i = 0; i < torrent->info.pieceCount; ++i )
     
    775771    assert( weAreInterested == 0 || weAreInterested == 1 );
    776772
    777     msgs->info->clientIsInterested = weAreInterested;
     773    msgs->peer->clientIsInterested = weAreInterested;
    778774    dbgmsg( msgs, "Sending %s", weAreInterested ? "Interested" : "Not Interested" );
    779     tr_peerIoWriteUint32( msgs->io, out, sizeof( uint8_t ) );
    780     tr_peerIoWriteUint8 ( msgs->io, out, weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
     775    tr_peerIoWriteUint32( msgs->peer->io, out, sizeof( uint8_t ) );
     776    tr_peerIoWriteUint8 ( msgs->peer->io, out, weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
    781777    pokeBatchPeriod( msgs, HIGH_PRIORITY_INTERVAL_SECS );
    782778    dbgOutMessageLen( msgs );
     
    788784    const int i = isPeerInteresting( msgs );
    789785
    790     if( i != msgs->info->clientIsInterested )
     786    if( i != msgs->peer->clientIsInterested )
    791787        sendInterest( msgs, i );
    792788    if( i )
     
    805801{
    806802    struct peer_request req;
    807     const int mustSendCancel = tr_peerIoSupportsFEXT( msgs->io );
     803    const int mustSendCancel = tr_peerIoSupportsFEXT( msgs->peer->io );
    808804
    809805    while( popNextRequest( msgs, &req ) )
     
    820816
    821817    assert( msgs );
    822     assert( msgs->info );
     818    assert( msgs->peer );
    823819    assert( choke == 0 || choke == 1 );
    824820
    825     if( msgs->info->chokeChangedAt > fibrillationTime )
     821    if( msgs->peer->chokeChangedAt > fibrillationTime )
    826822    {
    827823        dbgmsg( msgs, "Not changing choke to %d to avoid fibrillation", choke );
    828824    }
    829     else if( msgs->info->peerIsChoked != choke )
    830     {
    831         msgs->info->peerIsChoked = choke;
     825    else if( msgs->peer->peerIsChoked != choke )
     826    {
     827        msgs->peer->peerIsChoked = choke;
    832828        if( choke )
    833829            cancelAllRequestsToClient( msgs );
    834830        protocolSendChoke( msgs, choke );
    835         msgs->info->chokeChangedAt = now;
     831        msgs->peer->chokeChangedAt = now;
    836832    }
    837833}
     
    876872    time_t oldestAllowed;
    877873    struct request_list tmp = REQUEST_LIST_INIT;
    878     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
     874    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
    879875
    880876    /* cancel requests that have been queued for too long */
     
    913909    if( count > min )
    914910        return;
    915     if( msgs->info->clientIsChoked )
     911    if( msgs->peer->clientIsChoked )
    916912        return;
    917913    if( !tr_torrentIsPieceTransferAllowed( msgs->torrent, TR_PEER_TO_CLIENT ) )
     
    923919
    924920        assert( requestIsValid( msgs, &req ) );
    925         assert( tr_bitfieldHas( msgs->info->have, req.index ) );
     921        assert( tr_bitfieldHas( msgs->peer->have, req.index ) );
    926922
    927923        /* don't ask for it if we've already got it... this block may have
     
    973969
    974970    /* don't send requests to choked clients */
    975     if( !doForce && msgs->info->clientIsChoked ) {
     971    if( !doForce && msgs->peer->clientIsChoked ) {
    976972        dbgmsg( msgs, "declining request because they're choking us" );
    977973        return TR_ADDREQ_CLIENT_CHOKED;
     
    979975
    980976    /* peer doesn't have this piece */
    981     if( !doForce && !tr_bitfieldHas( msgs->info->have, index ) )
     977    if( !doForce && !tr_bitfieldHas( msgs->peer->have, index ) )
    982978        return TR_ADDREQ_MISSING;
    983979
     
    11071103    buf = tr_bencSave( &val, &len );
    11081104
    1109     tr_peerIoWriteUint32( msgs->io, out, 2 * sizeof( uint8_t ) + len );
    1110     tr_peerIoWriteUint8 ( msgs->io, out, BT_LTEP );
    1111     tr_peerIoWriteUint8 ( msgs->io, out, LTEP_HANDSHAKE );
    1112     tr_peerIoWriteBytes ( msgs->io, out, buf, len );
     1105    tr_peerIoWriteUint32( msgs->peer->io, out, 2 * sizeof( uint8_t ) + len );
     1106    tr_peerIoWriteUint8 ( msgs->peer->io, out, BT_LTEP );
     1107    tr_peerIoWriteUint8 ( msgs->peer->io, out, LTEP_HANDSHAKE );
     1108    tr_peerIoWriteBytes ( msgs->peer->io, out, buf, len );
    11131109    pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
    11141110    dbgOutMessageLen( msgs );
     
    11281124    uint8_t * tmp = tr_new( uint8_t, len );
    11291125
    1130     tr_peerIoReadBytes( msgs->io, inbuf, tmp, len );
     1126    tr_peerIoReadBytes( msgs->peer->io, inbuf, tmp, len );
    11311127    msgs->peerSentLtepHandshake = 1;
    11321128
     
    11421138    /* does the peer prefer encrypted connections? */
    11431139    if( tr_bencDictFindInt( &val, "e", &i ) )
    1144         msgs->info->encryption_preference = i ? ENCRYPTION_PREFERENCE_YES
     1140        msgs->peer->encryption_preference = i ? ENCRYPTION_PREFERENCE_YES
    11451141                                              : ENCRYPTION_PREFERENCE_NO;
    11461142
     
    11611157    /* get peer's listening port */
    11621158    if( tr_bencDictFindInt( &val, "p", &i ) ) {
    1163         msgs->info->port = htons( (uint16_t)i );
    1164         dbgmsg( msgs, "msgs->port is now %hu", msgs->info->port );
     1159        msgs->peer->port = htons( (uint16_t)i );
     1160        dbgmsg( msgs, "msgs->port is now %hu", msgs->peer->port );
    11651161    }
    11661162
     
    11831179    size_t added_len;
    11841180
    1185     tr_peerIoReadBytes( msgs->io, inbuf, tmp, msglen );
     1181    tr_peerIoReadBytes( msgs->peer->io, inbuf, tmp, msglen );
    11861182
    11871183    if( tr_torrentAllowsPex( tor )
     
    12151211    uint8_t ltep_msgid;
    12161212
    1217     tr_peerIoReadUint8( msgs->io, inbuf, &ltep_msgid );
     1213    tr_peerIoReadUint8( msgs->peer->io, inbuf, &ltep_msgid );
    12181214    msglen--;
    12191215
     
    12221218        dbgmsg( msgs, "got ltep handshake" );
    12231219        parseLtepHandshake( msgs, msglen, inbuf );
    1224         if( tr_peerIoSupportsLTEP( msgs->io ) )
     1220        if( tr_peerIoSupportsLTEP( msgs->peer->io ) )
    12251221        {
    12261222            sendLtepHandshake( msgs );
     
    12511247        return READ_LATER;
    12521248
    1253     tr_peerIoReadUint32( msgs->io, inbuf, &len );
     1249    tr_peerIoReadUint32( msgs->peer->io, inbuf, &len );
    12541250
    12551251    if( len == 0 ) /* peer sent us a keepalive message */
     
    12781274        return READ_LATER;
    12791275
    1280     tr_peerIoReadUint8( msgs->io, inbuf, &id );
     1276    tr_peerIoReadUint8( msgs->peer->io, inbuf, &id );
    12811277    msgs->incoming.id = id;
    12821278
     
    12971293updatePeerProgress( tr_peermsgs * msgs )
    12981294{
    1299     msgs->info->progress = tr_bitfieldCountTrueBits( msgs->info->have ) / (float)msgs->torrent->info.pieceCount;
    1300     dbgmsg( msgs, "peer progress is %f", msgs->info->progress );
     1295    msgs->peer->progress = tr_bitfieldCountTrueBits( msgs->peer->have ) / (float)msgs->torrent->info.pieceCount;
     1296    dbgmsg( msgs, "peer progress is %f", msgs->peer->progress );
    13011297    updateFastSet( msgs );
    13021298    updateInterest( msgs );
     
    13081304                 const struct peer_request * req )
    13091305{
    1310     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
     1306    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
    13111307    const int reqIsValid = requestIsValid( msgs, req );
    13121308    const int clientHasPiece = reqIsValid && tr_cpPieceIsComplete( msgs->torrent->completion, req->index );
    1313     const int peerIsChoked = msgs->info->peerIsChoked;
     1309    const int peerIsChoked = msgs->peer->peerIsChoked;
    13141310
    13151311    int allow = FALSE;
     
    13901386            return READ_LATER;
    13911387
    1392         tr_peerIoReadUint32( msgs->io, inbuf, &req->index );
    1393         tr_peerIoReadUint32( msgs->io, inbuf, &req->offset );
     1388        tr_peerIoReadUint32( msgs->peer->io, inbuf, &req->index );
     1389        tr_peerIoReadUint32( msgs->peer->io, inbuf, &req->offset );
    13941390        req->length = msgs->incoming.length - 9;
    13951391        dbgmsg( msgs, "got incoming block header %u:%u->%u", req->index, req->offset, req->length );
     
    14051401        uint8_t * buf = tr_new( uint8_t, n );
    14061402        assert( EVBUFFER_LENGTH( inbuf ) >= n );
    1407         tr_peerIoReadBytes( msgs->io, inbuf, buf, n );
     1403        tr_peerIoReadBytes( msgs->peer->io, inbuf, buf, n );
    14081404        evbuffer_add( msgs->incoming.block, buf, n );
    14091405        fireClientGotData( msgs, n, TRUE );
     
    14391435    const uint8_t id = msgs->incoming.id;
    14401436    const size_t  startBufLen = EVBUFFER_LENGTH( inbuf );
    1441     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
     1437    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
    14421438
    14431439    --msglen; /* id length */
     
    14591455        case BT_CHOKE:
    14601456            dbgmsg( msgs, "got Choke" );
    1461             msgs->info->clientIsChoked = 1;
     1457            msgs->peer->clientIsChoked = 1;
    14621458            if( !fext )
    14631459                cancelAllRequestsToPeer( msgs, FALSE );
     
    14661462        case BT_UNCHOKE:
    14671463            dbgmsg( msgs, "got Unchoke" );
    1468             msgs->info->clientIsChoked = 0;
     1464            msgs->peer->clientIsChoked = 0;
    14691465            fireNeedReq( msgs );
    14701466            break;
     
    14721468        case BT_INTERESTED:
    14731469            dbgmsg( msgs, "got Interested" );
    1474             msgs->info->peerIsInterested = 1;
     1470            msgs->peer->peerIsInterested = 1;
    14751471            break;
    14761472
    14771473        case BT_NOT_INTERESTED:
    14781474            dbgmsg( msgs, "got Not Interested" );
    1479             msgs->info->peerIsInterested = 0;
     1475            msgs->peer->peerIsInterested = 0;
    14801476            break;
    14811477
    14821478        case BT_HAVE:
    1483             tr_peerIoReadUint32( msgs->io, inbuf, &ui32 );
     1479            tr_peerIoReadUint32( msgs->peer->io, inbuf, &ui32 );
    14841480            dbgmsg( msgs, "got Have: %u", ui32 );
    1485             if( tr_bitfieldAdd( msgs->info->have, ui32 ) ) {
     1481            if( tr_bitfieldAdd( msgs->peer->have, ui32 ) ) {
    14861482                fireError( msgs, ERANGE );
    14871483                return READ_ERR;
     
    14961492            dbgmsg( msgs, "got a bitfield" );
    14971493            msgs->peerSentBitfield = 1;
    1498             tr_peerIoReadBytes( msgs->io, inbuf, msgs->info->have->bits, msglen );
     1494            tr_peerIoReadBytes( msgs->peer->io, inbuf, msgs->peer->have->bits, msglen );
    14991495            updatePeerProgress( msgs );
    15001496            fireNeedReq( msgs );
     
    15051501        {
    15061502            struct peer_request r;
    1507             tr_peerIoReadUint32( msgs->io, inbuf, &r.index );
    1508             tr_peerIoReadUint32( msgs->io, inbuf, &r.offset );
    1509             tr_peerIoReadUint32( msgs->io, inbuf, &r.length );
     1503            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
     1504            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
     1505            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
    15101506            dbgmsg( msgs, "got Request: %u:%u->%u", r.index, r.offset, r.length );
    15111507            peerMadeRequest( msgs, &r );
     
    15161512        {
    15171513            struct peer_request r;
    1518             tr_peerIoReadUint32( msgs->io, inbuf, &r.index );
    1519             tr_peerIoReadUint32( msgs->io, inbuf, &r.offset );
    1520             tr_peerIoReadUint32( msgs->io, inbuf, &r.length );
     1514            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
     1515            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
     1516            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
    15211517            dbgmsg( msgs, "got a Cancel %u:%u->%u", r.index, r.offset, r.length );
    15221518            if( reqListRemove( &msgs->peerAskedFor, &r ) && fext )
     
    15311527        case BT_PORT:
    15321528            dbgmsg( msgs, "Got a BT_PORT" );
    1533             tr_peerIoReadUint16( msgs->io, inbuf, &msgs->info->port );
     1529            tr_peerIoReadUint16( msgs->peer->io, inbuf, &msgs->peer->port );
    15341530            break;
    15351531
    15361532        case BT_FEXT_SUGGEST:
    15371533            dbgmsg( msgs, "Got a BT_FEXT_SUGGEST" );
    1538             tr_peerIoReadUint32( msgs->io, inbuf, &ui32 );
     1534            tr_peerIoReadUint32( msgs->peer->io, inbuf, &ui32 );
    15391535            if( fext )
    15401536                fireClientGotSuggest( msgs, ui32 );
     
    15471543        case BT_FEXT_ALLOWED_FAST:
    15481544            dbgmsg( msgs, "Got a BT_FEXT_ALLOWED_FAST" );
    1549             tr_peerIoReadUint32( msgs->io, inbuf, &ui32 );
     1545            tr_peerIoReadUint32( msgs->peer->io, inbuf, &ui32 );
    15501546            if( fext )
    15511547                fireClientGotAllowedFast( msgs, ui32 );
     
    15591555            dbgmsg( msgs, "Got a BT_FEXT_HAVE_ALL" );
    15601556            if( fext ) {
    1561                 tr_bitfieldAddRange( msgs->info->have, 0, msgs->torrent->info.pieceCount );
     1557                tr_bitfieldAddRange( msgs->peer->have, 0, msgs->torrent->info.pieceCount );
    15621558                updatePeerProgress( msgs );
    15631559            } else {
     
    15711567            dbgmsg( msgs, "Got a BT_FEXT_HAVE_NONE" );
    15721568            if( fext ) {
    1573                 tr_bitfieldClear( msgs->info->have );
     1569                tr_bitfieldClear( msgs->peer->have );
    15741570                updatePeerProgress( msgs );
    15751571            } else {
     
    15831579            struct peer_request r;
    15841580            dbgmsg( msgs, "Got a BT_FEXT_REJECT" );
    1585             tr_peerIoReadUint32( msgs->io, inbuf, &r.index );
    1586             tr_peerIoReadUint32( msgs->io, inbuf, &r.offset );
    1587             tr_peerIoReadUint32( msgs->io, inbuf, &r.length );
     1581            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
     1582            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
     1583            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
    15881584            if( fext )
    15891585                reqListRemove( &msgs->clientAskedFor, &r );
     
    16021598        default:
    16031599            dbgmsg( msgs, "peer sent us an UNKNOWN: %d", (int)id );
    1604             tr_peerIoDrain( msgs->io, inbuf, msglen );
     1600            tr_peerIoDrain( msgs->peer->io, inbuf, msglen );
    16051601            break;
    16061602    }
     
    16301626addPeerToBlamefield( tr_peermsgs * msgs, uint32_t index )
    16311627{
    1632     if( !msgs->info->blame )
    1633          msgs->info->blame = tr_bitfieldNew( msgs->torrent->info.pieceCount );
    1634     tr_bitfieldAdd( msgs->info->blame, index );
     1628    if( !msgs->peer->blame )
     1629         msgs->peer->blame = tr_bitfieldNew( msgs->torrent->info.pieceCount );
     1630    tr_bitfieldAdd( msgs->peer->blame, index );
    16351631}
    16361632
     
    17481744{
    17491745    tr_peermsgs * msgs = vmsgs;
    1750     const double rateToClient = tr_peerGetPieceSpeed( msgs->info, TR_PEER_TO_CLIENT );
     1746    const double rateToClient = tr_peerGetPieceSpeed( msgs->peer, TR_PEER_TO_CLIENT );
    17511747    const int estimatedBlocksInNext30Seconds =
    17521748                  ( rateToClient * 30 * 1024 ) / msgs->torrent->blockSize;
     
    17641760    struct peer_request req;
    17651761    const int haveMessages = EVBUFFER_LENGTH( msgs->outMessages ) != 0;
    1766     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
     1762    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
    17671763
    17681764    /**
     
    17791775        const size_t len = EVBUFFER_LENGTH( msgs->outMessages );
    17801776        /* flush the protocol messages */
    1781         dbgmsg( msgs, "flushing outMessages... to %p (length is %zu)", msgs->io, len );
    1782         tr_peerIoWriteBuf( msgs->io, msgs->outMessages, FALSE );
     1777        dbgmsg( msgs, "flushing outMessages... to %p (length is %zu)", msgs->peer->io, len );
     1778        tr_peerIoWriteBuf( msgs->peer->io, msgs->outMessages, FALSE );
    17831779        msgs->clientSentAnythingAt = now;
    17841780        msgs->outMessagesBatchedAt = 0;
     
    17911787    **/
    17921788
    1793     if( ( tr_peerIoGetWriteBufferSpace( msgs->io ) >= msgs->torrent->blockSize )
     1789    if( ( tr_peerIoGetWriteBufferSpace( msgs->peer->io ) >= msgs->torrent->blockSize )
    17941790        && popNextRequest( msgs, &req ) )
    17951791    {
     
    18051801                msgs = NULL;
    18061802            } else {
    1807                 tr_peerIo * io = msgs->io;
     1803                tr_peerIo * io = msgs->peer->io;
    18081804                struct evbuffer * out = evbuffer_new( );
    18091805                dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length );
     
    18351831    {
    18361832        dbgmsg( msgs, "sending a keepalive message" );
    1837         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, 0 );
     1833        tr_peerIoWriteUint32( msgs->peer->io, msgs->outMessages, 0 );
    18381834        pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
    18391835    }
     
    19191915    }
    19201916
    1921     tr_peerIoWriteUint32( msgs->io, out,
     1917    tr_peerIoWriteUint32( msgs->peer->io, out,
    19221918                          sizeof( uint8_t ) + field->byteCount );
    1923     tr_peerIoWriteUint8 ( msgs->io, out, BT_BITFIELD );
    1924     tr_peerIoWriteBytes ( msgs->io, out, field->bits, field->byteCount );
     1919    tr_peerIoWriteUint8 ( msgs->peer->io, out, BT_BITFIELD );
     1920    tr_peerIoWriteBytes ( msgs->peer->io, out, field->bits, field->byteCount );
    19251921    dbgmsg( msgs, "sending bitfield... outMessage size is now %zu",
    19261922            EVBUFFER_LENGTH( out ) );
     
    19361932tellPeerWhatWeHave( tr_peermsgs * msgs )
    19371933{
    1938     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->io );
     1934    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
    19391935
    19401936    if( fext && ( tr_cpGetStatus( msgs->torrent->completion ) == TR_SEED ) )
     
    20892085            /* write the pex message */
    20902086            benc = tr_bencSave( &val, &bencLen );
    2091             tr_peerIoWriteUint32( msgs->io, out, 2 * sizeof( uint8_t ) + bencLen );
    2092             tr_peerIoWriteUint8 ( msgs->io, out, BT_LTEP );
    2093             tr_peerIoWriteUint8 ( msgs->io, out, msgs->ut_pex_id );
    2094             tr_peerIoWriteBytes ( msgs->io, out, benc, bencLen );
     2087            tr_peerIoWriteUint32( msgs->peer->io, out, 2 * sizeof( uint8_t ) + bencLen );
     2088            tr_peerIoWriteUint8 ( msgs->peer->io, out, BT_LTEP );
     2089            tr_peerIoWriteUint8 ( msgs->peer->io, out, msgs->ut_pex_id );
     2090            tr_peerIoWriteBytes ( msgs->peer->io, out, benc, bencLen );
    20952091            pokeBatchPeriod( msgs, HIGH_PRIORITY_INTERVAL_SECS );
    20962092            dbgmsg( msgs, "sending a pex message; outMessage size is now %zu", EVBUFFER_LENGTH( out ) );
     
    21342130    m = tr_new0( tr_peermsgs, 1 );
    21352131    m->publisher = tr_publisherNew( );
    2136     m->info = peer;
     2132    m->peer = peer;
    21372133    m->session = torrent->session;
    21382134    m->torrent = torrent;
    2139     m->io = peer->io;
    2140     m->info->clientIsChoked = 1;
    2141     m->info->peerIsChoked = 1;
    2142     m->info->clientIsInterested = 0;
    2143     m->info->peerIsInterested = 0;
    2144     m->info->have = tr_bitfieldNew( torrent->info.pieceCount );
     2135    m->peer->clientIsChoked = 1;
     2136    m->peer->peerIsChoked = 1;
     2137    m->peer->clientIsInterested = 0;
     2138    m->peer->peerIsInterested = 0;
     2139    m->peer->have = tr_bitfieldNew( torrent->info.pieceCount );
    21452140    m->state = AWAITING_BT_LENGTH;
    21462141    m->pexTimer = tr_timerNew( m->session, pexPulse, m, PEX_INTERVAL );
     
    21492144    m->outMessagesBatchPeriod = LOW_PRIORITY_INTERVAL_SECS;
    21502145    m->incoming.block = evbuffer_new( );
    2151     m->peerAllowedPieces = NULL;
    21522146    m->peerAskedFor = REQUEST_LIST_INIT;
    21532147    m->clientAskedFor = REQUEST_LIST_INIT;
     
    21572151    *setme = tr_publisherSubscribe( m->publisher, func, userData );
    21582152
    2159     if( tr_peerIoSupportsLTEP( m->io ) )
     2153    if( tr_peerIoSupportsLTEP( peer->io ) )
    21602154        sendLtepHandshake( m );
    21612155
    21622156    tellPeerWhatWeHave( m );
    21632157
    2164     tr_peerIoSetTimeoutSecs( m->io, 150 ); /* timeout after N seconds of inactivity */
    2165     tr_peerIoSetIOFuncs( m->io, canRead, didWrite, gotError, m );
     2158    tr_peerIoSetTimeoutSecs( m->peer->io, 150 ); /* timeout after N seconds of inactivity */
     2159    tr_peerIoSetIOFuncs( m->peer->io, canRead, didWrite, gotError, m );
    21662160    ratePulse( m );
    21672161
     
    21802174        reqListClear( &msgs->peerAskedFor );
    21812175
    2182         tr_bitfieldFree( msgs->peerAllowedPieces );
    21832176        evbuffer_free( msgs->incoming.block );
    21842177        evbuffer_free( msgs->outMessages );
Note: See TracChangeset for help on using the changeset viewer.