{"action":"created","comment":{"url":"https://api.github.com/repos/hyperledger/iroha/pulls/comments/232629712","pull_request_review_id":173866045,"id":232629712,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjYyOTcxMg==","diff_hunk":"@@ -0,0 +1,40 @@\n+/**\n+ * Copyright Soramitsu Co., Ltd. All Rights Reserved.\n+ * SPDX-License-Identifier: Apache-2.0\n+ */\n+\n+#include \"ordering/impl/ordering_gate_cache/on_demand_cache.hpp\"\n+\n+using namespace iroha::ordering::cache;\n+\n+void OnDemandCache::addToBack(\n+    const OrderingGateCache::BatchesSetType &batches) {\n+  std::unique_lock<std::shared_timed_mutex> lock(mutex_);","path":"irohad/ordering/impl/ordering_gate_cache/on_demand_cache.cpp","position":12,"original_position":12,"commit_id":"ed65fd0b1314b39d53847f2c1dfaf380e0bce1ad","original_commit_id":"ed65fd0b1314b39d53847f2c1dfaf380e0bce1ad","user":{"login":"kamilsa","id":9370151,"node_id":"MDQ6VXNlcjkzNzAxNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/9370151?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilsa","html_url":"https://github.com/kamilsa","followers_url":"https://api.github.com/users/kamilsa/followers","following_url":"https://api.github.com/users/kamilsa/following{/other_user}","gists_url":"https://api.github.com/users/kamilsa/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilsa/subscriptions","organizations_url":"https://api.github.com/users/kamilsa/orgs","repos_url":"https://api.github.com/users/kamilsa/repos","events_url":"https://api.github.com/users/kamilsa/events{/privacy}","received_events_url":"https://api.github.com/users/kamilsa/received_events","type":"User","site_admin":false},"body":"I think it is matter of the taste of developer. Also here it is part of the logic since we should tell for the code readers that this method can only be executed synchronously with other methods in that class. Achieving the same result by adding more instances to the code will only make it more complicated. Any strong objectives to refactor that code?","created_at":"2018-11-12T11:54:11Z","updated_at":"2018-11-12T11:54:12Z","html_url":"https://github.com/hyperledger/iroha/pull/1805#discussion_r232629712","pull_request_url":"https://api.github.com/repos/hyperledger/iroha/pulls/1805","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/comments/232629712"},"html":{"href":"https://github.com/hyperledger/iroha/pull/1805#discussion_r232629712"},"pull_request":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/1805"}},"in_reply_to_id":232565248},"pull_request":{"url":"https://api.github.com/repos/hyperledger/iroha/pulls/1805","id":225421185,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1NDIxMTg1","html_url":"https://github.com/hyperledger/iroha/pull/1805","diff_url":"https://github.com/hyperledger/iroha/pull/1805.diff","patch_url":"https://github.com/hyperledger/iroha/pull/1805.patch","issue_url":"https://api.github.com/repos/hyperledger/iroha/issues/1805","number":1805,"state":"open","locked":false,"title":"Uncommitted caching","user":{"login":"kamilsa","id":9370151,"node_id":"MDQ6VXNlcjkzNzAxNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/9370151?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilsa","html_url":"https://github.com/kamilsa","followers_url":"https://api.github.com/users/kamilsa/followers","following_url":"https://api.github.com/users/kamilsa/following{/other_user}","gists_url":"https://api.github.com/users/kamilsa/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilsa/subscriptions","organizations_url":"https://api.github.com/users/kamilsa/orgs","repos_url":"https://api.github.com/users/kamilsa/repos","events_url":"https://api.github.com/users/kamilsa/events{/privacy}","received_events_url":"https://api.github.com/users/kamilsa/received_events","type":"User","site_admin":false},"body":"<!-- You will not see HTML commented line in Pull Request body -->\r\n<!-- Optional sections may be omitted. Just remove them or write None -->\r\n\r\n<!-- ### Requirements -->\r\n<!-- * Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. -->\r\n<!-- * All new code must have code coverage above 70% (https://docs.codecov.io/docs/about-code-coverage). -->\r\n<!-- * CircleCI builds must be passed. -->\r\n<!-- * Critical and blocker issues reported by Sorabot must be fixed. -->\r\n<!-- * Branch must be rebased onto base branch (https://soramitsu.atlassian.net/wiki/spaces/IS/pages/11173889/Rebase+and+merge+guide). -->\r\n\r\n\r\n### Description of the Change\r\n\r\nAdds caching of uncommitted transactions. Cache works as the queue of batches collections. Queue's size is always 3. It works as follows:\r\n\r\n#### `OnDemandOrderingGate::propagateBatch(Batch B)` is invoked:\r\n\r\ngiven the following state of the cache:\r\n\r\n```\r\nhead\r\n1. {a, b, c}\r\n2. {d, e}\r\n3. {f, g}\r\ntail\r\n```\r\n\r\n1. The batches from the head of the queue are concatenated with the batch\r\n`batches = {a, b, c, B}`\r\n2. Batches are sent to network\r\n3. The head of the queue is cleaned\r\n```\r\n1. {}\r\n2. {d, e}\r\n3. {f, g}\r\n```\r\n4. Batches are added to the tail of the queue\r\n```\r\n1. {}\r\n2. {d, e}\r\n3. {f, g, a, b, c, B}\r\n```\r\n\r\n#### `BlockEvent` containing batches {a,b} is received from OS:\r\ngiven the following state of the cache:\r\n\r\n```\r\nhead\r\n1. {a, b, c}\r\n2. {d, e}\r\n3. {f, g}\r\ntail\r\n```\r\n\r\n1. `up` is invoked, which shifts all BatchLists towards the head. Batches from the middle ({d, e} in example) are concatenated with head batches ({a,b,c}):\r\n```\r\n1. {a, b, c, d, e}\r\n2. {f, g}\r\n3. {}\r\n```\r\n2. All batches from the event ({a,b}) are removed from the top:\r\n```\r\n1. {c, d, e}\r\n2. {f, g}\r\n3. {}\r\n```\r\n\r\n### Benefits\r\n\r\nThe transactions that were not committed will be resent to the network\r\n\r\n### Possible Drawbacks \r\n\r\nThe logic of the caching can be too sophisticated, and probably can be somehow simplified\r\n### Usage Examples or Tests\r\n\r\nTests for cache and for on demand ordering gate with cache added \r\n\r\n### Alternate Designs\r\n\r\nLive without caching\r\n","created_at":"2018-10-24T14:15:14Z","updated_at":"2018-11-12T11:54:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66424ca37cc9f710ca412eb0127a02923f984c8a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"lebdron","id":14347159,"node_id":"MDQ6VXNlcjE0MzQ3MTU5","avatar_url":"https://avatars1.githubusercontent.com/u/14347159?v=4","gravatar_id":"","url":"https://api.github.com/users/lebdron","html_url":"https://github.com/lebdron","followers_url":"https://api.github.com/users/lebdron/followers","following_url":"https://api.github.com/users/lebdron/following{/other_user}","gists_url":"https://api.github.com/users/lebdron/gists{/gist_id}","starred_url":"https://api.github.com/users/lebdron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lebdron/subscriptions","organizations_url":"https://api.github.com/users/lebdron/orgs","repos_url":"https://api.github.com/users/lebdron/repos","events_url":"https://api.github.com/users/lebdron/events{/privacy}","received_events_url":"https://api.github.com/users/lebdron/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperledger/iroha/pulls/1805/commits","review_comments_url":"https://api.github.com/repos/hyperledger/iroha/pulls/1805/comments","review_comment_url":"https://api.github.com/repos/hyperledger/iroha/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperledger/iroha/issues/1805/comments","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/ed65fd0b1314b39d53847f2c1dfaf380e0bce1ad","head":{"label":"hyperledger:feature/uncommited-caching","ref":"feature/uncommited-caching","sha":"ed65fd0b1314b39d53847f2c1dfaf380e0bce1ad","user":{"login":"hyperledger","id":7657900,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc2NTc5MDA=","avatar_url":"https://avatars2.githubusercontent.com/u/7657900?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":67340575,"node_id":"MDEwOlJlcG9zaXRvcnk2NzM0MDU3NQ==","name":"iroha","full_name":"hyperledger/iroha","private":false,"owner":{"login":"hyperledger","id":7657900,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc2NTc5MDA=","avatar_url":"https://avatars2.githubusercontent.com/u/7657900?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hyperledger/iroha","description":"Iroha - A simple, decentralized ledger","fork":false,"url":"https://api.github.com/repos/hyperledger/iroha","forks_url":"https://api.github.com/repos/hyperledger/iroha/forks","keys_url":"https://api.github.com/repos/hyperledger/iroha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/iroha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/iroha/teams","hooks_url":"https://api.github.com/repos/hyperledger/iroha/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/iroha/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/iroha/events","assignees_url":"https://api.github.com/repos/hyperledger/iroha/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/iroha/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/iroha/tags","blobs_url":"https://api.github.com/repos/hyperledger/iroha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/iroha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/iroha/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/iroha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/iroha/languages","stargazers_url":"https://api.github.com/repos/hyperledger/iroha/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/iroha/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/iroha/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/iroha/subscription","commits_url":"https://api.github.com/repos/hyperledger/iroha/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/iroha/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/iroha/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/iroha/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/iroha/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/iroha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/iroha/merges","archive_url":"https://api.github.com/repos/hyperledger/iroha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/iroha/downloads","issues_url":"https://api.github.com/repos/hyperledger/iroha/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/iroha/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/iroha/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/iroha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/iroha/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/iroha/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/iroha/deployments","created_at":"2016-09-04T11:17:53Z","updated_at":"2018-11-12T10:20:34Z","pushed_at":"2018-11-12T09:03:57Z","git_url":"git://github.com/hyperledger/iroha.git","ssh_url":"git@github.com:hyperledger/iroha.git","clone_url":"https://github.com/hyperledger/iroha.git","svn_url":"https://github.com/hyperledger/iroha","homepage":"http://iroha.tech","size":56680,"stargazers_count":968,"watchers_count":968,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":305,"mirror_url":null,"archived":false,"open_issues_count":58,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":305,"open_issues":58,"watchers":968,"default_branch":"master"}},"base":{"label":"hyperledger:dev","ref":"dev","sha":"51d7c82ca8c4d837a0be80d8a12b7851d308d86f","user":{"login":"hyperledger","id":7657900,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc2NTc5MDA=","avatar_url":"https://avatars2.githubusercontent.com/u/7657900?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":67340575,"node_id":"MDEwOlJlcG9zaXRvcnk2NzM0MDU3NQ==","name":"iroha","full_name":"hyperledger/iroha","private":false,"owner":{"login":"hyperledger","id":7657900,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc2NTc5MDA=","avatar_url":"https://avatars2.githubusercontent.com/u/7657900?v=4","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hyperledger/iroha","description":"Iroha - A simple, decentralized ledger","fork":false,"url":"https://api.github.com/repos/hyperledger/iroha","forks_url":"https://api.github.com/repos/hyperledger/iroha/forks","keys_url":"https://api.github.com/repos/hyperledger/iroha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/iroha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/iroha/teams","hooks_url":"https://api.github.com/repos/hyperledger/iroha/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/iroha/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/iroha/events","assignees_url":"https://api.github.com/repos/hyperledger/iroha/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/iroha/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/iroha/tags","blobs_url":"https://api.github.com/repos/hyperledger/iroha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/iroha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/iroha/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/iroha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/iroha/languages","stargazers_url":"https://api.github.com/repos/hyperledger/iroha/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/iroha/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/iroha/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/iroha/subscription","commits_url":"https://api.github.com/repos/hyperledger/iroha/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/iroha/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/iroha/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/iroha/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/iroha/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/iroha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/iroha/merges","archive_url":"https://api.github.com/repos/hyperledger/iroha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/iroha/downloads","issues_url":"https://api.github.com/repos/hyperledger/iroha/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/iroha/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/iroha/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/iroha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/iroha/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/iroha/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/iroha/deployments","created_at":"2016-09-04T11:17:53Z","updated_at":"2018-11-12T10:20:34Z","pushed_at":"2018-11-12T09:03:57Z","git_url":"git://github.com/hyperledger/iroha.git","ssh_url":"git@github.com:hyperledger/iroha.git","clone_url":"https://github.com/hyperledger/iroha.git","svn_url":"https://github.com/hyperledger/iroha","homepage":"http://iroha.tech","size":56680,"stargazers_count":968,"watchers_count":968,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":305,"mirror_url":null,"archived":false,"open_issues_count":58,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":305,"open_issues":58,"watchers":968,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/1805"},"html":{"href":"https://github.com/hyperledger/iroha/pull/1805"},"issue":{"href":"https://api.github.com/repos/hyperledger/iroha/issues/1805"},"comments":{"href":"https://api.github.com/repos/hyperledger/iroha/issues/1805/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/1805/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/1805/commits"},"statuses":{"href":"https://api.github.com/repos/hyperledger/iroha/statuses/ed65fd0b1314b39d53847f2c1dfaf380e0bce1ad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kamilsa"}}