tor->info.pieces[pp].priority = calculatePiecePriority( tor, pp, -1 );
}
+int
+tr_torrentPromoteTracker( tr_torrent * tor, int pos )
+{
+ int i;
+ int tier;
+
+ assert( tor != NULL );
+ assert( 0 <= pos && pos < tor->info.trackerCount );
+
+ tier = tor->info.trackers[pos].tier;
+
+ /* find the index of the first tracker in that tier */
+ for( i=0; i<tor->info.trackerCount; ++i )
+ if( tor->info.trackers[i].tier == tier )
+ break;
+
+ assert( i < tor->info.trackerCount );
+
+ /* swap them if they're not the same */
+ if( i != pos ) {
+ tr_tracker_info tmp = tor->info.trackers[i];
+ tor->info.trackers[i] = tor->info.trackers[pos];
+ tor->info.trackers[pos] = tmp;
+ }
+
+ /* return the new position of the tracker that started out at [pos] */
+ return i;
+}
+
struct RandomTracker
{
tr_tracker_info tracker;
void tr_torrentSetFileChecked ( tr_torrent *, tr_file_index_t file, int isChecked );
void tr_torrentUncheck ( tr_torrent * );
+int tr_torrentPromoteTracker ( tr_torrent *, int trackerIndex );
+
time_t* tr_torrentGetMTimes ( const tr_torrent *, int * setmeCount );
typedef enum
}
else if( response_code == HTTP_OK )
{
-#if 0
-/* FIXME */
/* multitracker spec: "if a connection with a tracker is
successful, it will be moved to the front of the tier." */
- const int i = t->addressIndex;
- const int j = t->tierFronts[i];
- const tr_tracker_info swap = t->addresses[i];
- t->addresses[i] = t->addresses[j];
- t->addresses[j] = swap;
-#endif
+ t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex );
}
else
{