From ef5bb89e918a0e77f1787c35814b5ad194e7eca4 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Fri, 11 Mar 2011 04:57:53 +0000 Subject: [PATCH] (trunk libT) optimization for ocelot. When seeding on a private tracker, ocelot omits other seeds from the list of peers returned. We can test for this and update our "seed probability" field accordingly. --- libtransmission/announcer.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index 6248f7890..430712039 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -488,8 +488,16 @@ publishError( tr_tier * tier, const char * msg ) } static int8_t -getSeedProbability( int seeds, int leechers ) +getSeedProbability( tr_tier * tier, int seeds, int leechers, int pex_count ) { + /* special case optimization: + ocelot omits seeds from peer lists sent to seeds on private trackers. + so check for that case... */ + if( ( leechers == pex_count ) && tr_torrentIsPrivate( tier->tor ) + && tr_torrentIsSeed( tier->tor ) + && ( seeds + leechers < NUMWANT ) ) + return 0; + if( !seeds ) return 0; @@ -504,12 +512,13 @@ publishPeersPex( tr_tier * tier, int seeds, int leechers, const tr_pex * pex, int n ) { tr_tracker_event e = TRACKER_EVENT_INIT; - e.messageType = TR_TRACKER_PEERS; - e.seedProbability = getSeedProbability( seeds, leechers ); + e.seedProbability = getSeedProbability( tier, seeds, leechers, n ); e.pex = pex; e.pexCount = n; + dbgmsg( tier, "got %d peers; seed probability %d", n, (int)e.seedProbability ); + if( tier->tor->tiers->callback != NULL ) tier->tor->tiers->callback( tier->tor, &e, NULL ); }