{"action":"created","comment":{"url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/comments/205805277","pull_request_review_id":141151411,"id":205805277,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTgwNTI3Nw==","diff_hunk":"@@ -13,60 +10,19 @@ pub trait Api {\n \n     /// Get one specific block (represented by its unique hash) from the\n     /// network\n-    fn get_block(&mut self, hash: HeaderHash) -> Result<Block>;\n-\n-    /// Fetch a finished epoch\n-    ///\n-    /// Note that calling this api too close to the windows of block instability will either likely\n-    /// result in failure to get the pack, or unexpected result.\n-    ///\n-    /// In the case of hermes, an epoch is pack only after the latest block of the epoch\n-    /// is considered immutable in the chain by being old enough; latest known block's date\n-    /// is tip.date() - k where k is typically around 2200 blocks. TODO this is a configurable\n-    /// parameter, so expect to be able to find the constant somewhere in the net::Config in the future.\n-    fn fetch_epoch(&mut self, config: &net::Config, storage: &mut Storage, fep: FetchEpochParams) -> Result<FetchEpochResult>;\n-}\n+    fn get_block(&mut self, hash: &HeaderHash) -> Result<RawBlock>;\n \n-/// Parameter for fetching a full epoch\n-///\n-/// the epoch_id refer to which full epoch we want to fetch,\n-/// which is either used to make sure we're getting the\n-/// right blocks in the native API, or directly as a way\n-/// to get the right epoch in the http API.\n-///\n-/// The upper bound hash is used for the native API to have\n-/// a way to query the blocks in a range. we always know\n-/// the genesis hash (coming from the configuration) and\n-/// the get_tip API (coming from querying a network node.\n-///\n-/// The previous_header_hash is the hash we used to make\n-/// sure that the chain is actually valid; this hash\n-/// which represent the latest known block in the previous epoch,\n-/// should be equal to the genesis block of the new epoch\n-/// that is going to be fetch\n-///\n-/// start_header_hash is only used in the native protocol\n-/// when downloading the first block of the chain,\n-/// since we can't start downloading at previous_header_hash\n-/// which point to a non valid block\n-#[derive(Debug)]\n-pub struct FetchEpochParams {\n-    pub epoch_id: EpochId,\n-    pub start_header_hash: HeaderHash,\n-    pub previous_header_hash: HeaderHash,\n-    pub upper_bound_hash: HeaderHash\n+    /// Get the blocks in the half-open interval (from, to] (if\n+    /// inclusive = false) or [from, to] (if inclusive = true). FIXME:\n+    /// the inclusive = true case is only needed because the native\n+    /// protocol doesn't support fetching from the genesis_prev hash.\n+    fn get_blocks(&mut self, from: &BlockRef, inclusive: bool, to: &BlockRef,\n+                   got_block: &mut FnMut(&HeaderHash, &Block, &RawBlock) -> ());","path":"exe-common/src/network/api.rs","position":62,"original_position":62,"commit_id":"72249c3d4bebec81b547684ee0b01fe8728c24ac","original_commit_id":"838719486cb8c446f8d96e119ed934f64304868b","user":{"login":"edolstra","id":1148549,"node_id":"MDQ6VXNlcjExNDg1NDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1148549?v=4","gravatar_id":"","url":"https://api.github.com/users/edolstra","html_url":"https://github.com/edolstra","followers_url":"https://api.github.com/users/edolstra/followers","following_url":"https://api.github.com/users/edolstra/following{/other_user}","gists_url":"https://api.github.com/users/edolstra/gists{/gist_id}","starred_url":"https://api.github.com/users/edolstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edolstra/subscriptions","organizations_url":"https://api.github.com/users/edolstra/orgs","repos_url":"https://api.github.com/users/edolstra/repos","events_url":"https://api.github.com/users/edolstra/events{/privacy}","received_events_url":"https://api.github.com/users/edolstra/received_events","type":"User","site_admin":false},"body":"It passes a Block to the callee because the callee might need it (and indeed `net_sync()` does), and the caller already has it (since it performs some checks on the blocks and get the previous block in some cases), so it's more efficient to not have to deserialize it twice.","created_at":"2018-07-27T15:05:28Z","updated_at":"2018-07-27T15:05:28Z","html_url":"https://github.com/input-output-hk/rust-cardano/pull/171#discussion_r205805277","pull_request_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/comments/205805277"},"html":{"href":"https://github.com/input-output-hk/rust-cardano/pull/171#discussion_r205805277"},"pull_request":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171"}},"in_reply_to_id":205798734},"pull_request":{"url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171","id":204369099,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MzY5MDk5","html_url":"https://github.com/input-output-hk/rust-cardano/pull/171","diff_url":"https://github.com/input-output-hk/rust-cardano/pull/171.diff","patch_url":"https://github.com/input-output-hk/rust-cardano/pull/171.patch","issue_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/171","number":171,"state":"open","locked":false,"title":"net_sync() improvements","user":{"login":"edolstra","id":1148549,"node_id":"MDQ6VXNlcjExNDg1NDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1148549?v=4","gravatar_id":"","url":"https://api.github.com/users/edolstra","html_url":"https://github.com/edolstra","followers_url":"https://api.github.com/users/edolstra/followers","following_url":"https://api.github.com/users/edolstra/following{/other_user}","gists_url":"https://api.github.com/users/edolstra/gists{/gist_id}","starred_url":"https://api.github.com/users/edolstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edolstra/subscriptions","organizations_url":"https://api.github.com/users/edolstra/orgs","repos_url":"https://api.github.com/users/edolstra/repos","events_url":"https://api.github.com/users/edolstra/events{/privacy}","received_events_url":"https://api.github.com/users/edolstra/received_events","type":"User","site_admin":false},"body":"This adds the following improvements:\r\n\r\n* It can synchronize up to the current tip, rather than just fetching entire epochs. Thus it will fetch individual blocks from the current epoch and store them as separate blobs on disk. When on a subsequent sync we have an entire epoch of blocks, they'll be packed into an epoch on disk.\r\n\r\n* It respects the blockchain parameter 'k'. Thus it won't pack blocks into an epoch until we're at least k blocks into the next epoch.\r\n\r\n* It maintains the `HEAD` tag to point to the most recently fetched tip. So it no longer relies on epochs to figure out from where to restart synchronization. In the future, we'll want a tip per peer (and probably a tag to point to the latest \"stable\" block).\r\n\r\n* `ariadne blockchain sync` now has a flag `--native` to force it to sync using a native peer rather than a Hermes peer. This is useful for testing the native protocol.\r\n\r\n* Unrelated, added for testing: a command `ariadne ls-blocks` to list the blocks in the blockchain.\r\n\r\nNote that I changed `network::Api`: it no longer has a `fetch_epoch()` function. Instead, it has a `get_blocks()` function that fetches an arbitrary range of blocks. In the case of Hermes, this is optimized by fetching blocks in epochs, but that's an implementation detail that the caller doesn't need to know about. The reason for this change is that it simplifies `net_sync()` and `network::Api`, and it prevents the network layer from having a dependency on the storage layer.\r\n\r\nSome limitations:\r\n\r\n* It doesn't handle divergence yet: if the local tip is not an ancestor of the remote tip, it will barf. Obviously we'll need to handle this in the future (probably by restarting the sync from the latest stable block).\r\n\r\n* Fetching the individual blocks in the current epoch from Hermes could be slow on a high-latency connection.","created_at":"2018-07-27T08:52:57Z","updated_at":"2018-07-27T15:05:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e80b9ff4ec7f16c5e11d1da88a67a5afbac2e082","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171/commits","review_comments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171/comments","review_comment_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/comments{/number}","comments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/171/comments","statuses_url":"https://api.github.com/repos/input-output-hk/rust-cardano/statuses/72249c3d4bebec81b547684ee0b01fe8728c24ac","head":{"label":"input-output-hk:sync","ref":"sync","sha":"72249c3d4bebec81b547684ee0b01fe8728c24ac","user":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"repo":{"id":123330282,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMzMzAyODI=","name":"rust-cardano","full_name":"input-output-hk/rust-cardano","owner":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/input-output-hk/rust-cardano","description":null,"fork":false,"url":"https://api.github.com/repos/input-output-hk/rust-cardano","forks_url":"https://api.github.com/repos/input-output-hk/rust-cardano/forks","keys_url":"https://api.github.com/repos/input-output-hk/rust-cardano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/input-output-hk/rust-cardano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/input-output-hk/rust-cardano/teams","hooks_url":"https://api.github.com/repos/input-output-hk/rust-cardano/hooks","issue_events_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/events{/number}","events_url":"https://api.github.com/repos/input-output-hk/rust-cardano/events","assignees_url":"https://api.github.com/repos/input-output-hk/rust-cardano/assignees{/user}","branches_url":"https://api.github.com/repos/input-output-hk/rust-cardano/branches{/branch}","tags_url":"https://api.github.com/repos/input-output-hk/rust-cardano/tags","blobs_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/refs{/sha}","trees_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/input-output-hk/rust-cardano/statuses/{sha}","languages_url":"https://api.github.com/repos/input-output-hk/rust-cardano/languages","stargazers_url":"https://api.github.com/repos/input-output-hk/rust-cardano/stargazers","contributors_url":"https://api.github.com/repos/input-output-hk/rust-cardano/contributors","subscribers_url":"https://api.github.com/repos/input-output-hk/rust-cardano/subscribers","subscription_url":"https://api.github.com/repos/input-output-hk/rust-cardano/subscription","commits_url":"https://api.github.com/repos/input-output-hk/rust-cardano/commits{/sha}","git_commits_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/commits{/sha}","comments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/comments{/number}","issue_comment_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/comments{/number}","contents_url":"https://api.github.com/repos/input-output-hk/rust-cardano/contents/{+path}","compare_url":"https://api.github.com/repos/input-output-hk/rust-cardano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/input-output-hk/rust-cardano/merges","archive_url":"https://api.github.com/repos/input-output-hk/rust-cardano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/input-output-hk/rust-cardano/downloads","issues_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues{/number}","pulls_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls{/number}","milestones_url":"https://api.github.com/repos/input-output-hk/rust-cardano/milestones{/number}","notifications_url":"https://api.github.com/repos/input-output-hk/rust-cardano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/input-output-hk/rust-cardano/labels{/name}","releases_url":"https://api.github.com/repos/input-output-hk/rust-cardano/releases{/id}","deployments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/deployments","created_at":"2018-02-28T19:14:22Z","updated_at":"2018-07-27T13:32:40Z","pushed_at":"2018-07-27T15:02:32Z","git_url":"git://github.com/input-output-hk/rust-cardano.git","ssh_url":"git@github.com:input-output-hk/rust-cardano.git","clone_url":"https://github.com/input-output-hk/rust-cardano.git","svn_url":"https://github.com/input-output-hk/rust-cardano","homepage":null,"size":2630,"stargazers_count":31,"watchers_count":31,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":21,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":8,"open_issues":21,"watchers":31,"default_branch":"master"}},"base":{"label":"input-output-hk:master","ref":"master","sha":"424d173898346c12714ae42fbfe34f4d71d80399","user":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"repo":{"id":123330282,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMzMzAyODI=","name":"rust-cardano","full_name":"input-output-hk/rust-cardano","owner":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/input-output-hk/rust-cardano","description":null,"fork":false,"url":"https://api.github.com/repos/input-output-hk/rust-cardano","forks_url":"https://api.github.com/repos/input-output-hk/rust-cardano/forks","keys_url":"https://api.github.com/repos/input-output-hk/rust-cardano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/input-output-hk/rust-cardano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/input-output-hk/rust-cardano/teams","hooks_url":"https://api.github.com/repos/input-output-hk/rust-cardano/hooks","issue_events_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/events{/number}","events_url":"https://api.github.com/repos/input-output-hk/rust-cardano/events","assignees_url":"https://api.github.com/repos/input-output-hk/rust-cardano/assignees{/user}","branches_url":"https://api.github.com/repos/input-output-hk/rust-cardano/branches{/branch}","tags_url":"https://api.github.com/repos/input-output-hk/rust-cardano/tags","blobs_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/refs{/sha}","trees_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/input-output-hk/rust-cardano/statuses/{sha}","languages_url":"https://api.github.com/repos/input-output-hk/rust-cardano/languages","stargazers_url":"https://api.github.com/repos/input-output-hk/rust-cardano/stargazers","contributors_url":"https://api.github.com/repos/input-output-hk/rust-cardano/contributors","subscribers_url":"https://api.github.com/repos/input-output-hk/rust-cardano/subscribers","subscription_url":"https://api.github.com/repos/input-output-hk/rust-cardano/subscription","commits_url":"https://api.github.com/repos/input-output-hk/rust-cardano/commits{/sha}","git_commits_url":"https://api.github.com/repos/input-output-hk/rust-cardano/git/commits{/sha}","comments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/comments{/number}","issue_comment_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/comments{/number}","contents_url":"https://api.github.com/repos/input-output-hk/rust-cardano/contents/{+path}","compare_url":"https://api.github.com/repos/input-output-hk/rust-cardano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/input-output-hk/rust-cardano/merges","archive_url":"https://api.github.com/repos/input-output-hk/rust-cardano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/input-output-hk/rust-cardano/downloads","issues_url":"https://api.github.com/repos/input-output-hk/rust-cardano/issues{/number}","pulls_url":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls{/number}","milestones_url":"https://api.github.com/repos/input-output-hk/rust-cardano/milestones{/number}","notifications_url":"https://api.github.com/repos/input-output-hk/rust-cardano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/input-output-hk/rust-cardano/labels{/name}","releases_url":"https://api.github.com/repos/input-output-hk/rust-cardano/releases{/id}","deployments_url":"https://api.github.com/repos/input-output-hk/rust-cardano/deployments","created_at":"2018-02-28T19:14:22Z","updated_at":"2018-07-27T13:32:40Z","pushed_at":"2018-07-27T15:02:32Z","git_url":"git://github.com/input-output-hk/rust-cardano.git","ssh_url":"git@github.com:input-output-hk/rust-cardano.git","clone_url":"https://github.com/input-output-hk/rust-cardano.git","svn_url":"https://github.com/input-output-hk/rust-cardano","homepage":null,"size":2630,"stargazers_count":31,"watchers_count":31,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":21,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":8,"open_issues":21,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171"},"html":{"href":"https://github.com/input-output-hk/rust-cardano/pull/171"},"issue":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/171"},"comments":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/input-output-hk/rust-cardano/statuses/72249c3d4bebec81b547684ee0b01fe8728c24ac"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"edolstra"}}