Changeset 11578


Ignore:
Timestamp:
Dec 23, 2010, 2:35:21 AM (11 years ago)
Author:
livings124
Message:

#3595 Allow promotion of the "from" value in peer_atom (and still show where it was first discovered)

Location:
trunk
Files:
2 edited

Legend:

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

    r11553 r11578  
    122122struct peer_atom
    123123{
    124     uint8_t     from;
     124    uint8_t     fromFirst;          /* where the peer was first found */
     125    uint8_t     fromBest;           /* the "best" value of where the peer has been found */
    125126    uint8_t     flags;              /* these match the added_f flags */
    126127    uint8_t     flags2;             /* flags that aren't defined in added_f */
     
    151152{
    152153    return ( atom != NULL )
    153         && ( atom->from < TR_PEER_FROM__MAX )
     154        && ( atom->fromFirst < TR_PEER_FROM__MAX )
     155        && ( atom->fromBest < TR_PEER_FROM__MAX )
    154156        && ( tr_isAddress( &atom->addr ) );
    155157}
     
    15721574        a->port = port;
    15731575        a->flags = flags;
    1574         a->from = from;
     1576        a->fromFirst = from;
     1577        a->fromBest = from;
    15751578        a->shelf_date = tr_time( ) + getDefaultShelfLife( from ) + jitter;
    15761579        a->blocklisted = -1;
     
    15801583        tordbg( t, "got a new atom: %s", tr_atomAddrStr( a ) );
    15811584    }
    1582     else if( a->seedProbability == -1 )
    1583     {
    1584         atomSetSeedProbability( a, seedProbability );
     1585    else
     1586    {
     1587        if (from < a->fromBest)
     1588            a->fromBest = from;
     1589       
     1590        if( a->seedProbability == -1 )
     1591            atomSetSeedProbability( a, seedProbability );
    15851592    }
    15861593}
     
    19451952    if( a->piece_data_time != b->piece_data_time )
    19461953        return a->piece_data_time > b->piece_data_time ? -1 : 1;
    1947     if( a->from != b->from )
    1948         return a->from < b->from ? -1 : 1;
     1954    if( a->fromBest != b->fromBest )
     1955        return a->fromBest < b->fromBest ? -1 : 1;
    19491956    if( a->numFails != b->numFails )
    19501957        return a->numFails < b->numFails ? -1 : 1;
     
    22332240        ++*setmePeersConnected;
    22342241
    2235         ++setmePeersFrom[atom->from];
     2242        ++setmePeersFrom[atom->fromFirst];
    22362243
    22372244        if( clientIsDownloadingFrom( tor, peer ) )
     
    23422349                   sizeof( stat->client ) );
    23432350        stat->port                = ntohs( peer->atom->port );
    2344         stat->from                = atom->from;
     2351        stat->from                = atom->fromFirst;
    23452352        stat->progress            = peer->progress;
    23462353        stat->isEncrypted         = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
     
    23742381        if( stat->isEncrypted ) *pch++ = 'E';
    23752382        if( stat->from == TR_PEER_FROM_DHT ) *pch++ = 'H';
    2376         if( stat->from == TR_PEER_FROM_PEX ) *pch++ = 'X';
     2383        else if( stat->from == TR_PEER_FROM_PEX ) *pch++ = 'X';
    23772384        if( stat->isIncoming ) *pch++ = 'I';
    23782385        *pch = '\0';
     
    34543461
    34553462    /* Prefer peers that we got from more trusted sources.
    3456      * lower `from' values indicate more trusted sources */
    3457     score = addValToKey( score, 4, atom->from );
     3463     * lower `fromBest' values indicate more trusted sources */
     3464    score = addValToKey( score, 4, atom->fromBest );
    34583465
    34593466    /* salt */
  • trunk/macosx/InfoPeersViewController.m

    r11409 r11578  
    186186        if (connected > 0)
    187187        {
    188             NSMutableArray * fromComponents = [NSMutableArray arrayWithCapacity: 6];
     188            NSMutableArray * fromComponents = [NSMutableArray arrayWithCapacity: 7];
    189189            if (tracker > 0)
    190190                [fromComponents addObject: [NSString stringWithFormat:
Note: See TracChangeset for help on using the changeset viewer.