* Cache the current ceiling in rak::partial_queue.

* Added "enable_trackers=yes|no" option that can turn on/off the use
of trackers on all torrents.

* Cleanup of the API, including a new TrackerList class.

* When requesting from seeders, either continue a chunk another seeder
started or try a new one. This means seeders don't end up downloading
non-rare chunks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@658 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-28 21:04:07 +00:00
parent a811f53301
commit 8ea6f78e21
10 changed files with 108 additions and 64 deletions
+4
View File
@@ -133,6 +133,10 @@ private:
WINDOW* m_window;
};
// Undefines 'timeout' that ncurses defines which screws up the global
// namespace. Idiots; Especially you, ESR.
#undef timeout
}
#endif
+8 -7
View File
@@ -45,6 +45,7 @@
#include <torrent/connection_manager.h>
#include <torrent/rate.h>
#include <torrent/tracker.h>
#include <torrent/tracker_list.h>
#include "core/download.h"
@@ -76,7 +77,7 @@ print_hhmmss(char* first, char* last, time_t t) {
char*
print_ddhhmm(char* first, char* last, time_t t) {
if (t / (24 * 3600) < 100)
return print_buffer(first, last, "%2i:%02i:%02i", (int)t / (24 * 3600), ((int)t / 3600) % 24, ((int)t / 60) % 60);
return print_buffer(first, last, "%2id %2i:%02i", (int)t / (24 * 3600), ((int)t / 3600) % 24, ((int)t / 60) % 60);
else
return print_buffer(first, last, "--:--:--");
}
@@ -158,13 +159,13 @@ print_download_status(char* first, char* last, core::Download* d) {
(d->get_download().chunks_hashed() * 100) / d->get_download().chunks_total());
else if (d->get_download().is_tracker_busy() &&
d->get_download().tracker_focus() < d->get_download().size_trackers())
first = print_buffer(first, last, "Tracker[%i:%i]: Connecting to %s",
d->get_download().tracker(d->get_download().tracker_focus()).group(),
d->get_download().tracker_focus(),
d->get_download().tracker(d->get_download().tracker_focus()).url().c_str());
d->get_download().tracker_list().focus() < d->get_download().tracker_list().size()) {
torrent::TrackerList tl = d->get_download().tracker_list();
else if (!d->get_message().empty())
first = print_buffer(first, last, "Tracker[%i:%i]: Connecting to %s",
tl.get(tl.focus()).group(), tl.focus(), tl.get(tl.focus()).url().c_str());
} else if (!d->get_message().empty())
first = print_buffer(first, last, "%s", d->get_message().c_str());
else
+2 -1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <torrent/rate.h>
#include <torrent/tracker_list.h>
#include "canvas.h"
#include "globals.h"
@@ -85,7 +86,7 @@ WindowDownloadStatusbar::redraw() {
position = print_download_status(buffer, last, m_download);
m_canvas->print(0, 2, "[%c:%i] %s",
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(m_download->get_download().tracker_timeout() / 1000000),
(int)(m_download->get_download().tracker_list().timeout() / 1000000),
buffer);
}
+9 -9
View File
@@ -39,6 +39,7 @@
#include <stdexcept>
#include <rak/algorithm.h>
#include <rak/string_manip.h>
#include <torrent/tracker_list.h>
#include "core/download.h"
@@ -64,21 +65,20 @@ WindowTrackerList::redraw() {
++pos;
if (m_download->get_download().size_trackers() == 0)
torrent::TrackerList tl = m_download->get_download().tracker_list();
if (tl.size() == 0)
return;
if (*m_focus >= m_download->get_download().size_trackers())
throw std::logic_error("WindowTrackerList::redraw() called on an object with a bad focus value");
if (*m_focus >= tl.size())
throw std::logic_error("WindowTrackerList::redraw() called on an object with a bad focus value.");
typedef std::pair<unsigned int, unsigned int> Range;
Range range = rak::advance_bidirectional<unsigned int>(0,
*m_focus,
m_download->get_download().size_trackers(),
(m_canvas->get_height() + 1) / 2);
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tl.size(), (m_canvas->get_height() + 1) / 2);
while (range.first != range.second) {
torrent::Tracker t = m_download->get_download().tracker(range.first);
torrent::Tracker t = tl.get(range.first);
m_canvas->print(0, pos++, "%c %s",
range.first == *m_focus ? '*' : ' ',
@@ -88,7 +88,7 @@ WindowTrackerList::redraw() {
range.first == *m_focus ? '*' : ' ',
t.group(),
rak::copy_escape_html(t.tracker_id()).c_str(),
range.first == m_download->get_download().tracker_focus() ? "yes" : " no",
range.first == tl.focus() ? "yes" : " no",
t.is_enabled() ? "yes" : " no",
t.is_open() ? "yes" : " no",
t.scrape_complete(),