Ignore:
Timestamp:
Aug 13, 2006, 7:43:15 PM (15 years ago)
Author:
livings124
Message:

Some changes to getting peers in libtransmission. Now it uses a separate structure for the GUI accessing peers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/transmission.c

    r763 r764  
    406406}
    407407
    408 tr_peer_t * tr_getPeer( tr_torrent_t * tor, int peerNum)
    409 {
    410     tr_peer_t * peer;
    411 
    412     tr_lockLock( &tor->lock );
    413    
    414     if (peerNum < 0 || peerNum >= tor->peerCount)
    415         peer = NULL;
    416     else
    417         peer = tor->peers[peerNum];
    418        
    419     tr_lockUnlock( &tor->lock );
    420    
    421     return peer;
    422 }
    423 
    424408tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
    425409{
     
    449433    s->peersUploading   = 0;
    450434    s->peersDownloading = 0;
     435   
     436    tr_peer_t * peer;
     437    s->peers = (tr_peer_stat_t *) calloc( tor->peerCount, sizeof( tr_peer_stat_t ) );
    451438
    452439    for( i = 0; i < tor->peerCount; i++ )
    453440    {
    454         if( tr_peerIsConnected( tor->peers[i] ) )
     441        peer = tor->peers[i];
     442       
     443        char * client = tr_clientForId(tr_peerId(peer));
     444        char clientChar;
     445        int j = 0;
     446        while (j < 25 && (clientChar = client[j]) != 0)
     447        {
     448            s->peers[i].client[j] = clientChar;
     449            j++;
     450        }
     451       
     452        s->peers[i].isDownloading = tr_peerIsDownloading(peer);
     453        s->peers[i].isUploading = tr_peerIsUploading(peer);
     454   
     455        if( tr_peerIsConnected( peer ) )
    455456        {
    456457            (s->peersTotal)++;
    457             if( tr_peerIsUploading( tor->peers[i] ) )
     458            if( tr_peerIsUploading( peer ) )
    458459            {
    459460                (s->peersUploading)++;
    460461            }
    461             if( tr_peerIsDownloading( tor->peers[i] ) )
     462            if( tr_peerIsDownloading( peer ) )
    462463            {
    463464                (s->peersDownloading)++;
Note: See TracChangeset for help on using the changeset viewer.