Changeset 62


Ignore:
Timestamp:
Jan 30, 2006, 4:42:43 AM (15 years ago)
Author:
titer
Message:

Added a rate calculator for each peer
Set up files for the choking algorithm (does nothing yet)

Location:
trunk/libtransmission
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r61 r62  
    9696#include "ratecontrol.h"
    9797#include "clients.h"
     98#include "choking.h"
    9899
    99100struct tr_torrent_s
  • trunk/libtransmission/peer.c

    r61 r62  
    8282    uint64_t       outDate;
    8383    int            outSlow;
     84
     85    tr_ratecontrol_t * download;
    8486};
    8587
     
    173175        tr_fdSocketClosed( fdlimit, 0 );
    174176    }
     177    tr_rcClose( peer->download );
    175178    free( peer );
    176179}
     
    243246        if( NULL != tor )
    244247        {
     248            tr_rcTransferred( peer->download, ret );
    245249            tr_rcTransferred( tor->download, ret );
    246250            tr_rcTransferred( tor->globalDownload, ret );
     
    456460    return peer->bitfield;
    457461}
     462
     463float tr_peerDownloadRate( tr_peer_t * peer )
     464{
     465    return tr_rcRate( peer->download );
     466}
  • trunk/libtransmission/peer.h

    r26 r62  
    3939int         tr_peerIsDownloading ( tr_peer_t * );
    4040uint8_t *   tr_peerBitfield      ( tr_peer_t * );
     41float       tr_peerDownloadRate  ( tr_peer_t * );
    4142
    4243#endif
  • trunk/libtransmission/peerutils.h

    r60 r62  
    3737    peer->date        = tr_date();
    3838    peer->keepAlive   = peer->date;
     39    peer->download    = tr_rcInit();
    3940
    4041    return peer;
  • trunk/libtransmission/transmission.c

    r61 r62  
    578578{
    579579    tr_handle_t * h = _h;
    580     uint64_t      date1, date2;
     580    uint64_t      date1, date2, lastchoke = 0;
    581581    int           ii, jj;
    582582    uint8_t     * hash;
     583    tr_choking_t * choking = tr_chokingInit( h );
    583584
    584585    tr_dbg( "Accept thread started" );
     
    647648        }
    648649
     650        if( date1 > lastchoke + 2000 )
     651        {
     652            tr_chokingPulse( choking );
     653            lastchoke = date1;
     654        }
     655
    649656        /* Wait up to 20 ms */
    650657        date2 = tr_date();
     
    658665
    659666    tr_lockUnlock( &h->acceptLock );
     667    tr_chokingClose( choking );
    660668
    661669    tr_dbg( "Accept thread exited" );
Note: See TracChangeset for help on using the changeset viewer.