mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +00:00
* 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:
@@ -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++;
|
||||
|
||||
@@ -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&);
|
||||
|
||||
Reference in New Issue
Block a user