Changeset 10894 for branches


Ignore:
Timestamp:
Jun 27, 2010, 1:24:47 AM (12 years ago)
Author:
charles
Message:

(2.0x libT) add randomness to the peer unchoking algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0x/libtransmission/peer-mgr.c

    r10883 r10894  
    1212
    1313#include <assert.h>
     14#include <limits.h> /* INT_MAX */
    1415#include <string.h> /* memcpy, memcmp, strstr */
    1516#include <stdlib.h> /* qsort */
     
    25782579    tr_bool         isChoked;
    25792580    int             rate;
     2581    int             salt;
    25802582    tr_peer *       peer;
    25812583};
     
    25932595    if( a->isChoked != b->isChoked ) /* prefer unchoked */
    25942596        return a->isChoked ? 1 : -1;
     2597
     2598    if( a->salt != b->salt ) /* random order */
     2599        return a->salt - b->salt;
    25952600
    25962601    return 0;
     
    26412646            n->isChoked     = peer->peerIsChoked;
    26422647            n->rate         = tr_peerGetPieceSpeed( peer, now, TR_CLIENT_TO_PEER ) * 1024;
     2648            n->salt         = tr_cryptoWeakRandInt( INT_MAX );
    26432649        }
    26442650    }
Note: See TracChangeset for help on using the changeset viewer.