Skip to content

Instantly share code, notes, and snippets.

@sormy
Created October 24, 2017 04:45
Show Gist options
  • Save sormy/25404b53872e44f035cf204dfe14aae6 to your computer and use it in GitHub Desktop.
Save sormy/25404b53872e44f035cf204dfe14aae6 to your computer and use it in GitHub Desktop.
rtorrent/libtorrent sequential download patch
diff --git a/src/download/chunk_selector.cc b/src/download/chunk_selector.cc
index 850fec0f..248a29f9 100644
--- a/src/download/chunk_selector.cc
+++ b/src/download/chunk_selector.cc
@@ -82,7 +82,7 @@ ChunkSelector::update_priorities() {
m_sharedQueue.clear();
if (m_position == invalid_chunk)
- m_position = random() % size();
+ m_position = 0;
advance_position();
}
@@ -100,14 +100,6 @@ ChunkSelector::find(PeerChunks* pc, __UNUSED bool highPriority) {
// set.
rak::partial_queue* queue = pc->is_seeder() ? &m_sharedQueue : pc->download_cache();
- // Randomize position on average every 16 chunks to prevent
- // inefficient distribution with a slow seed and fast peers
- // all arriving at the same position.
- if ((random() & 63) == 0) {
- m_position = random() % size();
- queue->clear();
- }
-
if (queue->is_enabled()) {
// First check the cached queue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment