{"action":"created","comment":{"url":"https://api.github.com/repos/aeternity/epoch/pulls/comments/174445665","pull_request_review_id":103800462,"id":174445665,"diff_hunk":"@@ -431,64 +555,65 @@ agree_on_height(Uri, _, RH, LHeader, LH, Max, Min) when RH =/= LH ->\n          {error, Reason} ->\n              lager:debug(\"Fetching header ~p from ~p failed: ~p\", [LH, Uri, Reason]),\n              Min\n-    end.   \n+    end.\n \n do_server_get_missing(Uri) ->\n     aec_events:publish(chain_sync, {server_start, Uri}),\n     do_get_missing_blocks(Uri),\n     aec_events:publish(chain_sync, {server_done, Uri}).\n \n \n-fetch_chain(Uri, FromHeight, ToHeight, _) when FromHeight == ToHeight ->\n-    aec_events:publish(chain_sync, {client_done, Uri});\n-fetch_chain(Uri, FromH, ToH, HashFromH) when FromH < ToH ->\n-    case aeu_requests:get_header_by_height(Uri, FromH + 1) of\n-        {ok, Header} ->\n+fill_pool(Uri, RemoteHeight, AgreedHeight, AgreedHash) ->\n+    %% This should change to \"get next ?MAX_HEADERS_PER_CHUNK blocks\n+    %% starting from provided hash.\n+    Chunk = min(RemoteHeight - AgreedHeight, ?MAX_HEADERS_PER_CHUNK),\n+    case aeu_requests:get_block_by_height(Uri, AgreedHeight + Chunk) of\n+        {ok, Block} ->","path":"apps/aecore/src/aec_sync.erl","position":319,"original_position":319,"commit_id":"2d84e8185d5f3825a24f7763c1ed11ceb5836ec3","original_commit_id":"9602dee8b97ef306f41663c3a233b48537260307","user":{"login":"lucafavatella","id":1344255,"avatar_url":"https://avatars0.githubusercontent.com/u/1344255?v=4","gravatar_id":"","url":"https://api.github.com/users/lucafavatella","html_url":"https://github.com/lucafavatella","followers_url":"https://api.github.com/users/lucafavatella/followers","following_url":"https://api.github.com/users/lucafavatella/following{/other_user}","gists_url":"https://api.github.com/users/lucafavatella/gists{/gist_id}","starred_url":"https://api.github.com/users/lucafavatella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucafavatella/subscriptions","organizations_url":"https://api.github.com/users/lucafavatella/orgs","repos_url":"https://api.github.com/users/lucafavatella/repos","events_url":"https://api.github.com/users/lucafavatella/events{/privacy}","received_events_url":"https://api.github.com/users/lucafavatella/received_events","type":"User","site_admin":false},"body":"Who checks that the prev_hash in the received block makes sense for progressing towards the sync goal, and is not a random pruned/orphan block at that height?","created_at":"2018-03-14T12:44:31Z","updated_at":"2018-03-14T12:44:36Z","html_url":"https://github.com/aeternity/epoch/pull/857#discussion_r174445665","pull_request_url":"https://api.github.com/repos/aeternity/epoch/pulls/857","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/comments/174445665"},"html":{"href":"https://github.com/aeternity/epoch/pull/857#discussion_r174445665"},"pull_request":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/857"}}},"pull_request":{"url":"https://api.github.com/repos/aeternity/epoch/pulls/857","id":174900158,"html_url":"https://github.com/aeternity/epoch/pull/857","diff_url":"https://github.com/aeternity/epoch/pull/857.diff","patch_url":"https://github.com/aeternity/epoch/pull/857.patch","issue_url":"https://api.github.com/repos/aeternity/epoch/issues/857","number":857,"state":"open","locked":false,"title":"Pt 155428313 optimize retrieving blocks","user":{"login":"ThomasArts","id":638015,"avatar_url":"https://avatars1.githubusercontent.com/u/638015?v=4","gravatar_id":"","url":"https://api.github.com/users/ThomasArts","html_url":"https://github.com/ThomasArts","followers_url":"https://api.github.com/users/ThomasArts/followers","following_url":"https://api.github.com/users/ThomasArts/following{/other_user}","gists_url":"https://api.github.com/users/ThomasArts/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasArts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasArts/subscriptions","organizations_url":"https://api.github.com/users/ThomasArts/orgs","repos_url":"https://api.github.com/users/ThomasArts/repos","events_url":"https://api.github.com/users/ThomasArts/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasArts/received_events","type":"User","site_admin":false},"body":"We now fetch blocks from below and in parallel\r\n\r\n```erlang\r\n%% When we Ping a node with at least as much difficulty as we have, \r\n%% then we are going to sync with it.\r\n%% We already agree upon the genesis block and need to find the highest common\r\n%% block we agree upon. We use a binary search to find out.\r\n%% From the height we agree upon, we start asking for blocks to add to the chain.\r\n%% \r\n%% When an additional Ping arrives for which we agree upon genesis, we have\r\n%% the following possibilities:\r\n%% 1. It has worst top hash than our node, do not include in sync\r\n%% 2. It has better top hash than our node\r\n%%    We binary search for a node that we agree upon (could be genesis) \r\n%% We add new node to sync pool to sync agreed node upto top of new\r\n%% 1. If we are already synchronizing, we ignore it,\r\n%%    the ongoing sync will pick that up later\r\n%% 2. If we are not already synchronizing, we start doing so.\r\n%% \r\n%% We sync with several nodes at the same time and use as strategy \r\n%% to pick a random hash from the hashes in the pool.\r\n```\r\n","created_at":"2018-03-14T09:45:44Z","updated_at":"2018-03-14T12:44:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ffe0db7de6232728f56bf9416a7b7ca977d6de1","assignee":null,"assignees":[],"requested_reviewers":[{"login":"uwiger","id":160216,"avatar_url":"https://avatars3.githubusercontent.com/u/160216?v=4","gravatar_id":"","url":"https://api.github.com/users/uwiger","html_url":"https://github.com/uwiger","followers_url":"https://api.github.com/users/uwiger/followers","following_url":"https://api.github.com/users/uwiger/following{/other_user}","gists_url":"https://api.github.com/users/uwiger/gists{/gist_id}","starred_url":"https://api.github.com/users/uwiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwiger/subscriptions","organizations_url":"https://api.github.com/users/uwiger/orgs","repos_url":"https://api.github.com/users/uwiger/repos","events_url":"https://api.github.com/users/uwiger/events{/privacy}","received_events_url":"https://api.github.com/users/uwiger/received_events","type":"User","site_admin":false},{"login":"gorillainduction","id":7676988,"avatar_url":"https://avatars2.githubusercontent.com/u/7676988?v=4","gravatar_id":"","url":"https://api.github.com/users/gorillainduction","html_url":"https://github.com/gorillainduction","followers_url":"https://api.github.com/users/gorillainduction/followers","following_url":"https://api.github.com/users/gorillainduction/following{/other_user}","gists_url":"https://api.github.com/users/gorillainduction/gists{/gist_id}","starred_url":"https://api.github.com/users/gorillainduction/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gorillainduction/subscriptions","organizations_url":"https://api.github.com/users/gorillainduction/orgs","repos_url":"https://api.github.com/users/gorillainduction/repos","events_url":"https://api.github.com/users/gorillainduction/events{/privacy}","received_events_url":"https://api.github.com/users/gorillainduction/received_events","type":"User","site_admin":false},{"login":"sennui","id":16958765,"avatar_url":"https://avatars3.githubusercontent.com/u/16958765?v=4","gravatar_id":"","url":"https://api.github.com/users/sennui","html_url":"https://github.com/sennui","followers_url":"https://api.github.com/users/sennui/followers","following_url":"https://api.github.com/users/sennui/following{/other_user}","gists_url":"https://api.github.com/users/sennui/gists{/gist_id}","starred_url":"https://api.github.com/users/sennui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sennui/subscriptions","organizations_url":"https://api.github.com/users/sennui/orgs","repos_url":"https://api.github.com/users/sennui/repos","events_url":"https://api.github.com/users/sennui/events{/privacy}","received_events_url":"https://api.github.com/users/sennui/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aeternity/epoch/pulls/857/commits","review_comments_url":"https://api.github.com/repos/aeternity/epoch/pulls/857/comments","review_comment_url":"https://api.github.com/repos/aeternity/epoch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aeternity/epoch/issues/857/comments","statuses_url":"https://api.github.com/repos/aeternity/epoch/statuses/2d84e8185d5f3825a24f7763c1ed11ceb5836ec3","head":{"label":"aeternity:PT-155428313-optimize-retrieving-blocks","ref":"PT-155428313-optimize-retrieving-blocks","sha":"2d84e8185d5f3825a24f7763c1ed11ceb5836ec3","user":{"login":"aeternity","id":21989234,"avatar_url":"https://avatars1.githubusercontent.com/u/21989234?v=4","gravatar_id":"","url":"https://api.github.com/users/aeternity","html_url":"https://github.com/aeternity","followers_url":"https://api.github.com/users/aeternity/followers","following_url":"https://api.github.com/users/aeternity/following{/other_user}","gists_url":"https://api.github.com/users/aeternity/gists{/gist_id}","starred_url":"https://api.github.com/users/aeternity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeternity/subscriptions","organizations_url":"https://api.github.com/users/aeternity/orgs","repos_url":"https://api.github.com/users/aeternity/repos","events_url":"https://api.github.com/users/aeternity/events{/privacy}","received_events_url":"https://api.github.com/users/aeternity/received_events","type":"Organization","site_admin":false},"repo":{"id":99802036,"name":"epoch","full_name":"aeternity/epoch","owner":{"login":"aeternity","id":21989234,"avatar_url":"https://avatars1.githubusercontent.com/u/21989234?v=4","gravatar_id":"","url":"https://api.github.com/users/aeternity","html_url":"https://github.com/aeternity","followers_url":"https://api.github.com/users/aeternity/followers","following_url":"https://api.github.com/users/aeternity/following{/other_user}","gists_url":"https://api.github.com/users/aeternity/gists{/gist_id}","starred_url":"https://api.github.com/users/aeternity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeternity/subscriptions","organizations_url":"https://api.github.com/users/aeternity/orgs","repos_url":"https://api.github.com/users/aeternity/repos","events_url":"https://api.github.com/users/aeternity/events{/privacy}","received_events_url":"https://api.github.com/users/aeternity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aeternity/epoch","description":"æternity testnet: solving scalability problems by making sense of state-channels ","fork":false,"url":"https://api.github.com/repos/aeternity/epoch","forks_url":"https://api.github.com/repos/aeternity/epoch/forks","keys_url":"https://api.github.com/repos/aeternity/epoch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aeternity/epoch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aeternity/epoch/teams","hooks_url":"https://api.github.com/repos/aeternity/epoch/hooks","issue_events_url":"https://api.github.com/repos/aeternity/epoch/issues/events{/number}","events_url":"https://api.github.com/repos/aeternity/epoch/events","assignees_url":"https://api.github.com/repos/aeternity/epoch/assignees{/user}","branches_url":"https://api.github.com/repos/aeternity/epoch/branches{/branch}","tags_url":"https://api.github.com/repos/aeternity/epoch/tags","blobs_url":"https://api.github.com/repos/aeternity/epoch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aeternity/epoch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aeternity/epoch/git/refs{/sha}","trees_url":"https://api.github.com/repos/aeternity/epoch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aeternity/epoch/statuses/{sha}","languages_url":"https://api.github.com/repos/aeternity/epoch/languages","stargazers_url":"https://api.github.com/repos/aeternity/epoch/stargazers","contributors_url":"https://api.github.com/repos/aeternity/epoch/contributors","subscribers_url":"https://api.github.com/repos/aeternity/epoch/subscribers","subscription_url":"https://api.github.com/repos/aeternity/epoch/subscription","commits_url":"https://api.github.com/repos/aeternity/epoch/commits{/sha}","git_commits_url":"https://api.github.com/repos/aeternity/epoch/git/commits{/sha}","comments_url":"https://api.github.com/repos/aeternity/epoch/comments{/number}","issue_comment_url":"https://api.github.com/repos/aeternity/epoch/issues/comments{/number}","contents_url":"https://api.github.com/repos/aeternity/epoch/contents/{+path}","compare_url":"https://api.github.com/repos/aeternity/epoch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aeternity/epoch/merges","archive_url":"https://api.github.com/repos/aeternity/epoch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aeternity/epoch/downloads","issues_url":"https://api.github.com/repos/aeternity/epoch/issues{/number}","pulls_url":"https://api.github.com/repos/aeternity/epoch/pulls{/number}","milestones_url":"https://api.github.com/repos/aeternity/epoch/milestones{/number}","notifications_url":"https://api.github.com/repos/aeternity/epoch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aeternity/epoch/labels{/name}","releases_url":"https://api.github.com/repos/aeternity/epoch/releases{/id}","deployments_url":"https://api.github.com/repos/aeternity/epoch/deployments","created_at":"2017-08-09T11:44:30Z","updated_at":"2018-03-14T11:39:50Z","pushed_at":"2018-03-14T12:11:48Z","git_url":"git://github.com/aeternity/epoch.git","ssh_url":"git@github.com:aeternity/epoch.git","clone_url":"https://github.com/aeternity/epoch.git","svn_url":"https://github.com/aeternity/epoch","homepage":"http://www.aeternity.com","size":5181,"stargazers_count":361,"watchers_count":361,"language":"Erlang","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":57,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc"},"forks":57,"open_issues":7,"watchers":361,"default_branch":"master"}},"base":{"label":"aeternity:master","ref":"master","sha":"1dfb2d17113eebba8d3f49074fd05ebe20bd52c1","user":{"login":"aeternity","id":21989234,"avatar_url":"https://avatars1.githubusercontent.com/u/21989234?v=4","gravatar_id":"","url":"https://api.github.com/users/aeternity","html_url":"https://github.com/aeternity","followers_url":"https://api.github.com/users/aeternity/followers","following_url":"https://api.github.com/users/aeternity/following{/other_user}","gists_url":"https://api.github.com/users/aeternity/gists{/gist_id}","starred_url":"https://api.github.com/users/aeternity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeternity/subscriptions","organizations_url":"https://api.github.com/users/aeternity/orgs","repos_url":"https://api.github.com/users/aeternity/repos","events_url":"https://api.github.com/users/aeternity/events{/privacy}","received_events_url":"https://api.github.com/users/aeternity/received_events","type":"Organization","site_admin":false},"repo":{"id":99802036,"name":"epoch","full_name":"aeternity/epoch","owner":{"login":"aeternity","id":21989234,"avatar_url":"https://avatars1.githubusercontent.com/u/21989234?v=4","gravatar_id":"","url":"https://api.github.com/users/aeternity","html_url":"https://github.com/aeternity","followers_url":"https://api.github.com/users/aeternity/followers","following_url":"https://api.github.com/users/aeternity/following{/other_user}","gists_url":"https://api.github.com/users/aeternity/gists{/gist_id}","starred_url":"https://api.github.com/users/aeternity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeternity/subscriptions","organizations_url":"https://api.github.com/users/aeternity/orgs","repos_url":"https://api.github.com/users/aeternity/repos","events_url":"https://api.github.com/users/aeternity/events{/privacy}","received_events_url":"https://api.github.com/users/aeternity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aeternity/epoch","description":"æternity testnet: solving scalability problems by making sense of state-channels ","fork":false,"url":"https://api.github.com/repos/aeternity/epoch","forks_url":"https://api.github.com/repos/aeternity/epoch/forks","keys_url":"https://api.github.com/repos/aeternity/epoch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aeternity/epoch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aeternity/epoch/teams","hooks_url":"https://api.github.com/repos/aeternity/epoch/hooks","issue_events_url":"https://api.github.com/repos/aeternity/epoch/issues/events{/number}","events_url":"https://api.github.com/repos/aeternity/epoch/events","assignees_url":"https://api.github.com/repos/aeternity/epoch/assignees{/user}","branches_url":"https://api.github.com/repos/aeternity/epoch/branches{/branch}","tags_url":"https://api.github.com/repos/aeternity/epoch/tags","blobs_url":"https://api.github.com/repos/aeternity/epoch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aeternity/epoch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aeternity/epoch/git/refs{/sha}","trees_url":"https://api.github.com/repos/aeternity/epoch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aeternity/epoch/statuses/{sha}","languages_url":"https://api.github.com/repos/aeternity/epoch/languages","stargazers_url":"https://api.github.com/repos/aeternity/epoch/stargazers","contributors_url":"https://api.github.com/repos/aeternity/epoch/contributors","subscribers_url":"https://api.github.com/repos/aeternity/epoch/subscribers","subscription_url":"https://api.github.com/repos/aeternity/epoch/subscription","commits_url":"https://api.github.com/repos/aeternity/epoch/commits{/sha}","git_commits_url":"https://api.github.com/repos/aeternity/epoch/git/commits{/sha}","comments_url":"https://api.github.com/repos/aeternity/epoch/comments{/number}","issue_comment_url":"https://api.github.com/repos/aeternity/epoch/issues/comments{/number}","contents_url":"https://api.github.com/repos/aeternity/epoch/contents/{+path}","compare_url":"https://api.github.com/repos/aeternity/epoch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aeternity/epoch/merges","archive_url":"https://api.github.com/repos/aeternity/epoch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aeternity/epoch/downloads","issues_url":"https://api.github.com/repos/aeternity/epoch/issues{/number}","pulls_url":"https://api.github.com/repos/aeternity/epoch/pulls{/number}","milestones_url":"https://api.github.com/repos/aeternity/epoch/milestones{/number}","notifications_url":"https://api.github.com/repos/aeternity/epoch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aeternity/epoch/labels{/name}","releases_url":"https://api.github.com/repos/aeternity/epoch/releases{/id}","deployments_url":"https://api.github.com/repos/aeternity/epoch/deployments","created_at":"2017-08-09T11:44:30Z","updated_at":"2018-03-14T11:39:50Z","pushed_at":"2018-03-14T12:11:48Z","git_url":"git://github.com/aeternity/epoch.git","ssh_url":"git@github.com:aeternity/epoch.git","clone_url":"https://github.com/aeternity/epoch.git","svn_url":"https://github.com/aeternity/epoch","homepage":"http://www.aeternity.com","size":5181,"stargazers_count":361,"watchers_count":361,"language":"Erlang","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":57,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc"},"forks":57,"open_issues":7,"watchers":361,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/857"},"html":{"href":"https://github.com/aeternity/epoch/pull/857"},"issue":{"href":"https://api.github.com/repos/aeternity/epoch/issues/857"},"comments":{"href":"https://api.github.com/repos/aeternity/epoch/issues/857/comments"},"review_comments":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/857/comments"},"review_comment":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aeternity/epoch/pulls/857/commits"},"statuses":{"href":"https://api.github.com/repos/aeternity/epoch/statuses/2d84e8185d5f3825a24f7763c1ed11ceb5836ec3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"lucafavatella"}}