{"action":"created","comment":{"url":"https://api.github.com/repos/status-im/status-react/pulls/comments/185428084","pull_request_review_id":116806015,"id":185428084,"diff_hunk":"@@ -25,18 +26,17 @@\n                          (protocol/init-chat chat-id)))))\n \n (handlers/register-handler-fx\n- ::add-new-sym-key\n- (fn [{:keys [db] :as cofx} [_ {:keys [sym-key-id sym-key chat-id]}]]\n-   (let [{:keys [web3]} db]\n-     (handlers-macro/merge-fx\n-      cofx\n-      {:db                        (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id)\n-       :shh/add-filter            {:web3       web3\n-                                   :sym-key-id sym-key-id\n-                                   :topic      (transport.utils/get-topic chat-id)\n-                                   :chat-id    chat-id}\n-       :data-store.transport/save {:chat-id chat-id\n-                                   :chat    (-> (get-in db [:transport/chats chat-id])\n-                                                (assoc :sym-key-id sym-key-id)\n-                                                ;;TODO (yenda) remove once go implements persistence\n-                                                (assoc :sym-key sym-key))}}))))\n+  ::add-new-sym-key","path":"src/status_im/transport/message/v1/public_chat.cljs","position":29,"original_position":29,"commit_id":"e9a63b92e4f7ab64388fccbf218891603ca5d705","original_commit_id":"e9a63b92e4f7ab64388fccbf218891603ca5d705","user":{"login":"rasom","id":2364994,"avatar_url":"https://avatars2.githubusercontent.com/u/2364994?v=4","gravatar_id":"","url":"https://api.github.com/users/rasom","html_url":"https://github.com/rasom","followers_url":"https://api.github.com/users/rasom/followers","following_url":"https://api.github.com/users/rasom/following{/other_user}","gists_url":"https://api.github.com/users/rasom/gists{/gist_id}","starred_url":"https://api.github.com/users/rasom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasom/subscriptions","organizations_url":"https://api.github.com/users/rasom/orgs","repos_url":"https://api.github.com/users/rasom/repos","events_url":"https://api.github.com/users/rasom/events{/privacy}","received_events_url":"https://api.github.com/users/rasom/received_events","type":"User","site_admin":false},"body":"unnecessary changes","created_at":"2018-05-02T08:42:36Z","updated_at":"2018-05-02T08:43:04Z","html_url":"https://github.com/status-im/status-react/pull/4079#discussion_r185428084","pull_request_url":"https://api.github.com/repos/status-im/status-react/pulls/4079","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/status-im/status-react/pulls/comments/185428084"},"html":{"href":"https://github.com/status-im/status-react/pull/4079#discussion_r185428084"},"pull_request":{"href":"https://api.github.com/repos/status-im/status-react/pulls/4079"}}},"pull_request":{"url":"https://api.github.com/repos/status-im/status-react/pulls/4079","id":185302076,"html_url":"https://github.com/status-im/status-react/pull/4079","diff_url":"https://github.com/status-im/status-react/pull/4079.diff","patch_url":"https://github.com/status-im/status-react/pull/4079.patch","issue_url":"https://api.github.com/repos/status-im/status-react/issues/4079","number":4079,"state":"open","locked":false,"title":"Realm transactions","user":{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},"body":"[comment]: # (Please replace ... with your information. Remove < and >)\r\n[comment]: # (To auto-close issue on merge, please insert the related issue number after # i.e fixes #566)\r\n\r\nThis PR implements transaction compacting for all realm writes/updates/deletes. Previously, we performed each distinct realm operation inside `.write` block, even when we performed multiple such in span of one handler (like adding message, where message needs to be written, chat updated, etc.).\r\nNot only was that not very effective (`.write` blocks denoting transactions are expensive):\r\n![screen shot 2018-05-02 at 09 55 05](https://user-images.githubusercontent.com/1910609/39511857-3253c772-4def-11e8-9e37-ffd91b3ce17a.png)\r\n \r\nIt was also logically wrong, because each handler app-db change is atomic operation (it either succeeds or fails), but that was not true for realm operations, where it could happen that some of the realm objects were written correctly, while some of them not, leading to inconsistent (persisted) state.\r\n\r\nThis PR address the point by adding `:data-source/tx` and `:data-source/base-tx` effects (for account/base realm respectively) + reworking the `data-source.ENTITY` namespaces to expose public functions modelling transaction operations.\r\n`merge-fx` macro was updated to take special care of those effects, collecting all the transaction operations and issuing them as one transaction (one realm `.write` block) at the end.\r\nI also removed all the `data-source.realm.ENTITY` namespace, as that was just unnecessary burden, which resulted in quite a big code size reduction (almost 300LOC less).\r\n\r\n### Testing notes (optional):\r\nComplete regression testing with focus on persistence, eq if things are behaving correctly after app restart/s\r\n\r\nstatus: ready\r\n","created_at":"2018-05-01T23:35:28Z","updated_at":"2018-05-02T08:43:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b862212483dc8cc0f549a422685cbe3a84302fce","assignee":{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},"assignees":[{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"mandrigin","id":466427,"avatar_url":"https://avatars0.githubusercontent.com/u/466427?v=4","gravatar_id":"","url":"https://api.github.com/users/mandrigin","html_url":"https://github.com/mandrigin","followers_url":"https://api.github.com/users/mandrigin/followers","following_url":"https://api.github.com/users/mandrigin/following{/other_user}","gists_url":"https://api.github.com/users/mandrigin/gists{/gist_id}","starred_url":"https://api.github.com/users/mandrigin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mandrigin/subscriptions","organizations_url":"https://api.github.com/users/mandrigin/orgs","repos_url":"https://api.github.com/users/mandrigin/repos","events_url":"https://api.github.com/users/mandrigin/events{/privacy}","received_events_url":"https://api.github.com/users/mandrigin/received_events","type":"User","site_admin":false},{"login":"yenda","id":1181225,"avatar_url":"https://avatars1.githubusercontent.com/u/1181225?v=4","gravatar_id":"","url":"https://api.github.com/users/yenda","html_url":"https://github.com/yenda","followers_url":"https://api.github.com/users/yenda/followers","following_url":"https://api.github.com/users/yenda/following{/other_user}","gists_url":"https://api.github.com/users/yenda/gists{/gist_id}","starred_url":"https://api.github.com/users/yenda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenda/subscriptions","organizations_url":"https://api.github.com/users/yenda/orgs","repos_url":"https://api.github.com/users/yenda/repos","events_url":"https://api.github.com/users/yenda/events{/privacy}","received_events_url":"https://api.github.com/users/yenda/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":807362947,"url":"https://api.github.com/repos/status-im/status-react/labels/clojure","name":"clojure","color":"244ae2","default":false},{"id":783781483,"url":"https://api.github.com/repos/status-im/status-react/labels/performance","name":"performance","color":"dd3bd8","default":false},{"id":692308696,"url":"https://api.github.com/repos/status-im/status-react/labels/tech-debt","name":"tech-debt","color":"e99695","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/status-react/pulls/4079/commits","review_comments_url":"https://api.github.com/repos/status-im/status-react/pulls/4079/comments","review_comment_url":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/status-react/issues/4079/comments","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/e9a63b92e4f7ab64388fccbf218891603ca5d705","head":{"label":"status-im:feature/realm-transactions","ref":"feature/realm-transactions","sha":"e9a63b92e4f7ab64388fccbf218891603ca5d705","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-05-01T17:26:15Z","pushed_at":"2018-05-02T08:21:43Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":53764,"stargazers_count":2163,"watchers_count":2163,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":526,"mirror_url":null,"archived":false,"open_issues_count":596,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":526,"open_issues":596,"watchers":2163,"default_branch":"develop"}},"base":{"label":"status-im:develop","ref":"develop","sha":"e8301830117b47fc0c49acb95a63bc799b076ccf","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-05-01T17:26:15Z","pushed_at":"2018-05-02T08:21:43Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":53764,"stargazers_count":2163,"watchers_count":2163,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":526,"mirror_url":null,"archived":false,"open_issues_count":596,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":526,"open_issues":596,"watchers":2163,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/status-react/pulls/4079"},"html":{"href":"https://github.com/status-im/status-react/pull/4079"},"issue":{"href":"https://api.github.com/repos/status-im/status-react/issues/4079"},"comments":{"href":"https://api.github.com/repos/status-im/status-react/issues/4079/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/status-react/pulls/4079/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/status-react/pulls/4079/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/status-react/statuses/e9a63b92e4f7ab64388fccbf218891603ca5d705"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rasom"}}