{"action":"created","comment":{"url":"https://api.github.com/repos/lbryio/lbry/pulls/comments/132995354","pull_request_review_id":56128617,"id":132995354,"diff_hunk":"@@ -146,57 +150,58 @@ def _send_secondary_requests(self, peer, protocol):\n     @defer.inlineCallbacks\n     def manage(self, schedule_next_call=True):\n         self._manage_deferred = defer.Deferred()\n-        if len(self._peer_connections) < conf.settings['max_connections_per_stream']:\n+        if len(self._peer_connections) < self.max_connections_per_stream:\n             log.debug(\"%s have %d connections, looking for %d\",\n                         self._get_log_name(), len(self._peer_connections),\n-                        conf.settings['max_connections_per_stream'])\n-            ordered_request_creators = self._rank_request_creator_connections()\n-            peers = yield self._get_new_peers(ordered_request_creators)\n-            new_conns = conf.settings['max_connections_per_stream'] - len(self._peer_connections)\n-            peers = self._pick_best_peers(peers, new_conns)\n+                        self.max_connections_per_stream)\n+            peers = yield self._get_new_peers()\n             for peer in peers:\n                 self._connect_to_peer(peer)\n         self._manage_deferred.callback(None)\n         self._manage_deferred = None\n         if not self.stopped and schedule_next_call:\n             self._next_manage_call = utils.call_later(self.MANAGE_CALL_INTERVAL_SEC, self.manage)\n \n-    def _rank_request_creator_connections(self):\n-        \"\"\"Returns an ordered list of our request creators, ranked according\n-        to which has the least number of connections open that it\n-        likes\n-        \"\"\"\n-        def count_peers(request_creator):\n-            return len([\n-                p for p in self._peer_connections.itervalues()\n-                if request_creator in p.request_creators])\n-\n-        return sorted(self._primary_request_creators, key=count_peers)\n+    def return_shuffled_peers_not_connected_to(self, peers, new_conns_needed):\n+        if peers is None:\n+            # can happen if there is some error in the lookup\n+            return []\n+        out = [peer for peer in peers if peer not in self._peer_connections]\n+        random.shuffle(out)\n+        out = out[0:new_conns_needed]","path":"lbrynet/core/client/ConnectionManager.py","position":50,"original_position":50,"commit_id":"40ed9c4beff0b620dd0254f0f42e44b0d9eb4eb3","original_commit_id":"40ed9c4beff0b620dd0254f0f42e44b0d9eb4eb3","user":{"login":"jackrobison","id":11979920,"avatar_url":"https://avatars3.githubusercontent.com/u/11979920?v=4","gravatar_id":"","url":"https://api.github.com/users/jackrobison","html_url":"https://github.com/jackrobison","followers_url":"https://api.github.com/users/jackrobison/followers","following_url":"https://api.github.com/users/jackrobison/following{/other_user}","gists_url":"https://api.github.com/users/jackrobison/gists{/gist_id}","starred_url":"https://api.github.com/users/jackrobison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackrobison/subscriptions","organizations_url":"https://api.github.com/users/jackrobison/orgs","repos_url":"https://api.github.com/users/jackrobison/repos","events_url":"https://api.github.com/users/jackrobison/events{/privacy}","received_events_url":"https://api.github.com/users/jackrobison/received_events","type":"User","site_admin":false},"body":"This can just be `return out[:new_conns_needed]`\r\n","created_at":"2017-08-14T16:24:05Z","updated_at":"2017-08-14T16:59:36Z","html_url":"https://github.com/lbryio/lbry/pull/819#discussion_r132995354","pull_request_url":"https://api.github.com/repos/lbryio/lbry/pulls/819","_links":{"self":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/comments/132995354"},"html":{"href":"https://github.com/lbryio/lbry/pull/819#discussion_r132995354"},"pull_request":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/819"}}},"pull_request":{"url":"https://api.github.com/repos/lbryio/lbry/pulls/819","id":133760554,"html_url":"https://github.com/lbryio/lbry/pull/819","diff_url":"https://github.com/lbryio/lbry/pull/819.diff","patch_url":"https://github.com/lbryio/lbry/pull/819.patch","issue_url":"https://api.github.com/repos/lbryio/lbry/issues/819","number":819,"state":"open","locked":false,"title":"Add option for clients to seek head blob first when downloading ","user":{"login":"kaykurokawa","id":7075051,"avatar_url":"https://avatars2.githubusercontent.com/u/7075051?v=4","gravatar_id":"","url":"https://api.github.com/users/kaykurokawa","html_url":"https://github.com/kaykurokawa","followers_url":"https://api.github.com/users/kaykurokawa/followers","following_url":"https://api.github.com/users/kaykurokawa/following{/other_user}","gists_url":"https://api.github.com/users/kaykurokawa/gists{/gist_id}","starred_url":"https://api.github.com/users/kaykurokawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaykurokawa/subscriptions","organizations_url":"https://api.github.com/users/kaykurokawa/orgs","repos_url":"https://api.github.com/users/kaykurokawa/repos","events_url":"https://api.github.com/users/kaykurokawa/events{/privacy}","received_events_url":"https://api.github.com/users/kaykurokawa/received_events","type":"User","site_admin":false},"body":"This adds an option in conf for clients to download by prioritizing the seeking of the \"head blob\" (the very first blob in the stream) before they seek the next unavailable blob. \r\n\r\nIt is turned off by default in this PR so will not change how downloading works unless configured to be turned on manually.  Should be turned on when reflector switch to announcing head blob only. \r\n","created_at":"2017-08-02T17:03:30Z","updated_at":"2017-08-14T16:59:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"126a2e13c51365cca70c53879d297fa2882c12d0","assignee":{"login":"kaykurokawa","id":7075051,"avatar_url":"https://avatars2.githubusercontent.com/u/7075051?v=4","gravatar_id":"","url":"https://api.github.com/users/kaykurokawa","html_url":"https://github.com/kaykurokawa","followers_url":"https://api.github.com/users/kaykurokawa/followers","following_url":"https://api.github.com/users/kaykurokawa/following{/other_user}","gists_url":"https://api.github.com/users/kaykurokawa/gists{/gist_id}","starred_url":"https://api.github.com/users/kaykurokawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaykurokawa/subscriptions","organizations_url":"https://api.github.com/users/kaykurokawa/orgs","repos_url":"https://api.github.com/users/kaykurokawa/repos","events_url":"https://api.github.com/users/kaykurokawa/events{/privacy}","received_events_url":"https://api.github.com/users/kaykurokawa/received_events","type":"User","site_admin":false},"assignees":[{"login":"kaykurokawa","id":7075051,"avatar_url":"https://avatars2.githubusercontent.com/u/7075051?v=4","gravatar_id":"","url":"https://api.github.com/users/kaykurokawa","html_url":"https://github.com/kaykurokawa","followers_url":"https://api.github.com/users/kaykurokawa/followers","following_url":"https://api.github.com/users/kaykurokawa/following{/other_user}","gists_url":"https://api.github.com/users/kaykurokawa/gists{/gist_id}","starred_url":"https://api.github.com/users/kaykurokawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaykurokawa/subscriptions","organizations_url":"https://api.github.com/users/kaykurokawa/orgs","repos_url":"https://api.github.com/users/kaykurokawa/repos","events_url":"https://api.github.com/users/kaykurokawa/events{/privacy}","received_events_url":"https://api.github.com/users/kaykurokawa/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"lyoshenka","id":362784,"avatar_url":"https://avatars0.githubusercontent.com/u/362784?v=4","gravatar_id":"","url":"https://api.github.com/users/lyoshenka","html_url":"https://github.com/lyoshenka","followers_url":"https://api.github.com/users/lyoshenka/followers","following_url":"https://api.github.com/users/lyoshenka/following{/other_user}","gists_url":"https://api.github.com/users/lyoshenka/gists{/gist_id}","starred_url":"https://api.github.com/users/lyoshenka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyoshenka/subscriptions","organizations_url":"https://api.github.com/users/lyoshenka/orgs","repos_url":"https://api.github.com/users/lyoshenka/repos","events_url":"https://api.github.com/users/lyoshenka/events{/privacy}","received_events_url":"https://api.github.com/users/lyoshenka/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lbryio/lbry/pulls/819/commits","review_comments_url":"https://api.github.com/repos/lbryio/lbry/pulls/819/comments","review_comment_url":"https://api.github.com/repos/lbryio/lbry/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lbryio/lbry/issues/819/comments","statuses_url":"https://api.github.com/repos/lbryio/lbry/statuses/40ed9c4beff0b620dd0254f0f42e44b0d9eb4eb3","head":{"label":"lbryio:client_seek_head_blob_only","ref":"client_seek_head_blob_only","sha":"40ed9c4beff0b620dd0254f0f42e44b0d9eb4eb3","user":{"login":"lbryio","id":13889222,"avatar_url":"https://avatars3.githubusercontent.com/u/13889222?v=4","gravatar_id":"","url":"https://api.github.com/users/lbryio","html_url":"https://github.com/lbryio","followers_url":"https://api.github.com/users/lbryio/followers","following_url":"https://api.github.com/users/lbryio/following{/other_user}","gists_url":"https://api.github.com/users/lbryio/gists{/gist_id}","starred_url":"https://api.github.com/users/lbryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbryio/subscriptions","organizations_url":"https://api.github.com/users/lbryio/orgs","repos_url":"https://api.github.com/users/lbryio/repos","events_url":"https://api.github.com/users/lbryio/events{/privacy}","received_events_url":"https://api.github.com/users/lbryio/received_events","type":"Organization","site_admin":false},"repo":{"id":41103286,"name":"lbry","full_name":"lbryio/lbry","owner":{"login":"lbryio","id":13889222,"avatar_url":"https://avatars3.githubusercontent.com/u/13889222?v=4","gravatar_id":"","url":"https://api.github.com/users/lbryio","html_url":"https://github.com/lbryio","followers_url":"https://api.github.com/users/lbryio/followers","following_url":"https://api.github.com/users/lbryio/following{/other_user}","gists_url":"https://api.github.com/users/lbryio/gists{/gist_id}","starred_url":"https://api.github.com/users/lbryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbryio/subscriptions","organizations_url":"https://api.github.com/users/lbryio/orgs","repos_url":"https://api.github.com/users/lbryio/repos","events_url":"https://api.github.com/users/lbryio/events{/privacy}","received_events_url":"https://api.github.com/users/lbryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lbryio/lbry","description":"A fully decentralized network for distributing data","fork":false,"url":"https://api.github.com/repos/lbryio/lbry","forks_url":"https://api.github.com/repos/lbryio/lbry/forks","keys_url":"https://api.github.com/repos/lbryio/lbry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lbryio/lbry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lbryio/lbry/teams","hooks_url":"https://api.github.com/repos/lbryio/lbry/hooks","issue_events_url":"https://api.github.com/repos/lbryio/lbry/issues/events{/number}","events_url":"https://api.github.com/repos/lbryio/lbry/events","assignees_url":"https://api.github.com/repos/lbryio/lbry/assignees{/user}","branches_url":"https://api.github.com/repos/lbryio/lbry/branches{/branch}","tags_url":"https://api.github.com/repos/lbryio/lbry/tags","blobs_url":"https://api.github.com/repos/lbryio/lbry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lbryio/lbry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lbryio/lbry/git/refs{/sha}","trees_url":"https://api.github.com/repos/lbryio/lbry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lbryio/lbry/statuses/{sha}","languages_url":"https://api.github.com/repos/lbryio/lbry/languages","stargazers_url":"https://api.github.com/repos/lbryio/lbry/stargazers","contributors_url":"https://api.github.com/repos/lbryio/lbry/contributors","subscribers_url":"https://api.github.com/repos/lbryio/lbry/subscribers","subscription_url":"https://api.github.com/repos/lbryio/lbry/subscription","commits_url":"https://api.github.com/repos/lbryio/lbry/commits{/sha}","git_commits_url":"https://api.github.com/repos/lbryio/lbry/git/commits{/sha}","comments_url":"https://api.github.com/repos/lbryio/lbry/comments{/number}","issue_comment_url":"https://api.github.com/repos/lbryio/lbry/issues/comments{/number}","contents_url":"https://api.github.com/repos/lbryio/lbry/contents/{+path}","compare_url":"https://api.github.com/repos/lbryio/lbry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lbryio/lbry/merges","archive_url":"https://api.github.com/repos/lbryio/lbry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lbryio/lbry/downloads","issues_url":"https://api.github.com/repos/lbryio/lbry/issues{/number}","pulls_url":"https://api.github.com/repos/lbryio/lbry/pulls{/number}","milestones_url":"https://api.github.com/repos/lbryio/lbry/milestones{/number}","notifications_url":"https://api.github.com/repos/lbryio/lbry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lbryio/lbry/labels{/name}","releases_url":"https://api.github.com/repos/lbryio/lbry/releases{/id}","deployments_url":"https://api.github.com/repos/lbryio/lbry/deployments","created_at":"2015-08-20T15:24:10Z","updated_at":"2017-08-14T03:43:15Z","pushed_at":"2017-08-14T16:33:50Z","git_url":"git://github.com/lbryio/lbry.git","ssh_url":"git@github.com:lbryio/lbry.git","clone_url":"https://github.com/lbryio/lbry.git","svn_url":"https://github.com/lbryio/lbry","homepage":"https://lbry.io","size":5785,"stargazers_count":3331,"watchers_count":3331,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":135,"mirror_url":null,"open_issues_count":77,"forks":135,"open_issues":77,"watchers":3331,"default_branch":"master"}},"base":{"label":"lbryio:master","ref":"master","sha":"c7ba90181905748efebdcc74dfd358646c521679","user":{"login":"lbryio","id":13889222,"avatar_url":"https://avatars3.githubusercontent.com/u/13889222?v=4","gravatar_id":"","url":"https://api.github.com/users/lbryio","html_url":"https://github.com/lbryio","followers_url":"https://api.github.com/users/lbryio/followers","following_url":"https://api.github.com/users/lbryio/following{/other_user}","gists_url":"https://api.github.com/users/lbryio/gists{/gist_id}","starred_url":"https://api.github.com/users/lbryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbryio/subscriptions","organizations_url":"https://api.github.com/users/lbryio/orgs","repos_url":"https://api.github.com/users/lbryio/repos","events_url":"https://api.github.com/users/lbryio/events{/privacy}","received_events_url":"https://api.github.com/users/lbryio/received_events","type":"Organization","site_admin":false},"repo":{"id":41103286,"name":"lbry","full_name":"lbryio/lbry","owner":{"login":"lbryio","id":13889222,"avatar_url":"https://avatars3.githubusercontent.com/u/13889222?v=4","gravatar_id":"","url":"https://api.github.com/users/lbryio","html_url":"https://github.com/lbryio","followers_url":"https://api.github.com/users/lbryio/followers","following_url":"https://api.github.com/users/lbryio/following{/other_user}","gists_url":"https://api.github.com/users/lbryio/gists{/gist_id}","starred_url":"https://api.github.com/users/lbryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbryio/subscriptions","organizations_url":"https://api.github.com/users/lbryio/orgs","repos_url":"https://api.github.com/users/lbryio/repos","events_url":"https://api.github.com/users/lbryio/events{/privacy}","received_events_url":"https://api.github.com/users/lbryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lbryio/lbry","description":"A fully decentralized network for distributing data","fork":false,"url":"https://api.github.com/repos/lbryio/lbry","forks_url":"https://api.github.com/repos/lbryio/lbry/forks","keys_url":"https://api.github.com/repos/lbryio/lbry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lbryio/lbry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lbryio/lbry/teams","hooks_url":"https://api.github.com/repos/lbryio/lbry/hooks","issue_events_url":"https://api.github.com/repos/lbryio/lbry/issues/events{/number}","events_url":"https://api.github.com/repos/lbryio/lbry/events","assignees_url":"https://api.github.com/repos/lbryio/lbry/assignees{/user}","branches_url":"https://api.github.com/repos/lbryio/lbry/branches{/branch}","tags_url":"https://api.github.com/repos/lbryio/lbry/tags","blobs_url":"https://api.github.com/repos/lbryio/lbry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lbryio/lbry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lbryio/lbry/git/refs{/sha}","trees_url":"https://api.github.com/repos/lbryio/lbry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lbryio/lbry/statuses/{sha}","languages_url":"https://api.github.com/repos/lbryio/lbry/languages","stargazers_url":"https://api.github.com/repos/lbryio/lbry/stargazers","contributors_url":"https://api.github.com/repos/lbryio/lbry/contributors","subscribers_url":"https://api.github.com/repos/lbryio/lbry/subscribers","subscription_url":"https://api.github.com/repos/lbryio/lbry/subscription","commits_url":"https://api.github.com/repos/lbryio/lbry/commits{/sha}","git_commits_url":"https://api.github.com/repos/lbryio/lbry/git/commits{/sha}","comments_url":"https://api.github.com/repos/lbryio/lbry/comments{/number}","issue_comment_url":"https://api.github.com/repos/lbryio/lbry/issues/comments{/number}","contents_url":"https://api.github.com/repos/lbryio/lbry/contents/{+path}","compare_url":"https://api.github.com/repos/lbryio/lbry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lbryio/lbry/merges","archive_url":"https://api.github.com/repos/lbryio/lbry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lbryio/lbry/downloads","issues_url":"https://api.github.com/repos/lbryio/lbry/issues{/number}","pulls_url":"https://api.github.com/repos/lbryio/lbry/pulls{/number}","milestones_url":"https://api.github.com/repos/lbryio/lbry/milestones{/number}","notifications_url":"https://api.github.com/repos/lbryio/lbry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lbryio/lbry/labels{/name}","releases_url":"https://api.github.com/repos/lbryio/lbry/releases{/id}","deployments_url":"https://api.github.com/repos/lbryio/lbry/deployments","created_at":"2015-08-20T15:24:10Z","updated_at":"2017-08-14T03:43:15Z","pushed_at":"2017-08-14T16:33:50Z","git_url":"git://github.com/lbryio/lbry.git","ssh_url":"git@github.com:lbryio/lbry.git","clone_url":"https://github.com/lbryio/lbry.git","svn_url":"https://github.com/lbryio/lbry","homepage":"https://lbry.io","size":5785,"stargazers_count":3331,"watchers_count":3331,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":135,"mirror_url":null,"open_issues_count":77,"forks":135,"open_issues":77,"watchers":3331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/819"},"html":{"href":"https://github.com/lbryio/lbry/pull/819"},"issue":{"href":"https://api.github.com/repos/lbryio/lbry/issues/819"},"comments":{"href":"https://api.github.com/repos/lbryio/lbry/issues/819/comments"},"review_comments":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/819/comments"},"review_comment":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lbryio/lbry/pulls/819/commits"},"statuses":{"href":"https://api.github.com/repos/lbryio/lbry/statuses/40ed9c4beff0b620dd0254f0f42e44b0d9eb4eb3"}}}}
{"actor":{"display_login":"jackrobison"}}