* Applied a patch from josef that cleand up the chunks seen window.

* More work on rarity-first chunk selection.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@657 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-25 20:20:52 +00:00
parent b3051db2b2
commit a811f53301
3 changed files with 50 additions and 8 deletions
+22
View File
@@ -217,6 +217,28 @@ Download::priority_to_string(uint32_t p) {
}
}
float
Download::distributed_copies() const {
const uint8_t* avail = m_download.chunks_seen();
const uint8_t* end = avail + m_download.chunks_total();
if (avail == NULL)
return 0;
int minAvail = std::numeric_limits<uint8_t>::max();
int num = 0;
for (; avail < end; ++avail)
if (*avail == minAvail) {
num++;
} else if (*avail < minAvail) {
minAvail = *avail;
num = 1;
}
return minAvail + 1 - (float)num / m_download.chunks_total();
}
void
Download::receive_chunk_failed(__UNUSED uint32_t idx) {
m_chunksFailed++;
+2
View File
@@ -95,6 +95,8 @@ public:
static uint32_t string_to_priority(const std::string& name);
static const char* priority_to_string(uint32_t p);
float distributed_copies() const;
private:
Download(const Download&);
void operator () (const Download&);