Changeset 254


Ignore:
Timestamp:
May 13, 2006, 5:28:54 PM (15 years ago)
Author:
titer
Message:

Toughens the criteria for banning, tries to make guesses about the peers two got banned for a few pieces because of someone else

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer.c

    r253 r254  
    533533static inline int peerIsBad( tr_peer_t * peer )
    534534{
    535     if( peer->goodPcs >= 5 &&
    536         peer->badPcs >= ( peer->goodPcs * 3 ) )
    537     {
    538         /* need poor success rate if we've successfully downloaded before */
    539         return 1;
    540     }
    541     else if( peer->goodPcs < 5 &&
    542              peer->badPcs >= ( 10 + peer->goodPcs ) )
    543     {
    544         /* need 10 more bad pieces than good before we discard peer */
    545         return 1;
    546     }
    547     return 0;
     535    return ( peer->badPcs > 4 + 2 * peer->goodPcs );
     536}
     537
     538static inline int peerIsGood( tr_peer_t * peer )
     539{
     540    return ( peer->goodPcs > 3 * peer->badPcs );
    548541}
    549542
     
    559552    {
    560553        peer->goodPcs++;
     554
     555        if( peer->banfield && peerIsGood( peer ) )
     556        {
     557            /* Assume the peer wasn't responsible for the bad pieces
     558               we was banned for */
     559            memset( peer->banfield, 0x00, ( tor->info.pieceCount + 7 ) / 8 );
     560        }
    561561    }
    562562    else
     
    564564        peer->badPcs++;
    565565
     566        /* Ban the peer for this piece */
    566567        if( !peer->banfield )
    567568        {
Note: See TracChangeset for help on using the changeset viewer.