{"action":"created","comment":{"url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments/182428866","pull_request_review_id":113220765,"id":182428866,"diff_hunk":"@@ -56,6 +57,59 @@ contract LiquidDemocracy {\n \n         votersData[voterAddress].weight = 1;\n         votersData[voterAddress].registered = true;\n+        delegations[voterAddress] = voterAddress;\n+    }\n+\n+    // Delegations\n+\n+    /**\n+     * Delegate the voting power of a voter to another voter\n+     * Only the person calling this function has the power of delegating his/her vote\n+     * @param representative voter to delegate the voting power to\n+     */\n+    function delegate(address representative) public {\n+\n+        address representee = msg.sender;\n+        require(delegations[representee] == representee); // At the moment you can apply a delegation once\n+        require(votersData[representee].registered);\n+        require(votersData[representative].registered);\n+\n+        delegations[representee] = representative; // Delegate my own vote\n+\n+        address nextRepresentative = representative;\n+        address nextRepresentee = representee;\n+\n+        // While there is voter that hasn't performed a delegation to another voter\n+        // transitively add votes","path":"contracts/LiquidDemocracy.sol","position":46,"original_position":46,"commit_id":"76befc1bed97167835cb8d3b8102985b752d4d07","original_commit_id":"76befc1bed97167835cb8d3b8102985b752d4d07","user":{"login":"aecc","id":6069300,"avatar_url":"https://avatars0.githubusercontent.com/u/6069300?v=4","gravatar_id":"","url":"https://api.github.com/users/aecc","html_url":"https://github.com/aecc","followers_url":"https://api.github.com/users/aecc/followers","following_url":"https://api.github.com/users/aecc/following{/other_user}","gists_url":"https://api.github.com/users/aecc/gists{/gist_id}","starred_url":"https://api.github.com/users/aecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aecc/subscriptions","organizations_url":"https://api.github.com/users/aecc/orgs","repos_url":"https://api.github.com/users/aecc/repos","events_url":"https://api.github.com/users/aecc/events{/privacy}","received_events_url":"https://api.github.com/users/aecc/received_events","type":"User","site_admin":false},"body":"Yes, this will happen when starting simple. I'm not sure it can get more efficient than this though (at least with the tools we know), you need to update every voter's voting power in the delegation chain in the end, and we don't expect the delegation chains to be so long. So I would say the complexity is in the order of the number of the delegations in a chain (searching in hashmap is basically constant time, you need to do this n times, 1 per each delegation of the modified chain) The drawback from this approach (compared to a previous one that I did for Delegations.sol) is that it seems difficult to handle cycles (A -> B, B- > C. C-> A) at least from a fast look at it.","created_at":"2018-04-18T13:38:21Z","updated_at":"2018-04-18T13:38:21Z","html_url":"https://github.com/DemocracyEarth/contracts/pull/21#discussion_r182428866","pull_request_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments/182428866"},"html":{"href":"https://github.com/DemocracyEarth/contracts/pull/21#discussion_r182428866"},"pull_request":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21"}},"in_reply_to_id":182104410},"pull_request":{"url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21","id":181324081,"html_url":"https://github.com/DemocracyEarth/contracts/pull/21","diff_url":"https://github.com/DemocracyEarth/contracts/pull/21.diff","patch_url":"https://github.com/DemocracyEarth/contracts/pull/21.patch","issue_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21","number":21,"state":"open","locked":false,"title":"Added delegate() together with some tests","user":{"login":"aecc","id":6069300,"avatar_url":"https://avatars0.githubusercontent.com/u/6069300?v=4","gravatar_id":"","url":"https://api.github.com/users/aecc","html_url":"https://github.com/aecc","followers_url":"https://api.github.com/users/aecc/followers","following_url":"https://api.github.com/users/aecc/following{/other_user}","gists_url":"https://api.github.com/users/aecc/gists{/gist_id}","starred_url":"https://api.github.com/users/aecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aecc/subscriptions","organizations_url":"https://api.github.com/users/aecc/orgs","repos_url":"https://api.github.com/users/aecc/repos","events_url":"https://api.github.com/users/aecc/events{/privacy}","received_events_url":"https://api.github.com/users/aecc/received_events","type":"User","site_admin":false},"body":"Delegate() (#13) implemented and some minimal tests. We will probably have some conflicts, we can merge you PR first or second, as you wish.","created_at":"2018-04-12T20:59:33Z","updated_at":"2018-04-18T13:38:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e62faf7543ac1dab0431e18aa50c17eee6901a6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":868578114,"url":"https://api.github.com/repos/DemocracyEarth/contracts/labels/review","name":"review","color":"e6e6e6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/commits","review_comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/comments","review_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21/comments","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/76befc1bed97167835cb8d3b8102985b752d4d07","head":{"label":"DemocracyEarth:13-delegate","ref":"13-delegate","sha":"76befc1bed97167835cb8d3b8102985b752d4d07","user":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"repo":{"id":98763038,"name":"contracts","full_name":"DemocracyEarth/contracts","owner":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DemocracyEarth/contracts","description":"The social smart contract implementation","fork":false,"url":"https://api.github.com/repos/DemocracyEarth/contracts","forks_url":"https://api.github.com/repos/DemocracyEarth/contracts/forks","keys_url":"https://api.github.com/repos/DemocracyEarth/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemocracyEarth/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemocracyEarth/contracts/teams","hooks_url":"https://api.github.com/repos/DemocracyEarth/contracts/hooks","issue_events_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/DemocracyEarth/contracts/events","assignees_url":"https://api.github.com/repos/DemocracyEarth/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/DemocracyEarth/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/tags","blobs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/DemocracyEarth/contracts/languages","stargazers_url":"https://api.github.com/repos/DemocracyEarth/contracts/stargazers","contributors_url":"https://api.github.com/repos/DemocracyEarth/contracts/contributors","subscribers_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscribers","subscription_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscription","commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemocracyEarth/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/DemocracyEarth/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemocracyEarth/contracts/merges","archive_url":"https://api.github.com/repos/DemocracyEarth/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemocracyEarth/contracts/downloads","issues_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/DemocracyEarth/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/DemocracyEarth/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemocracyEarth/contracts/labels{/name}","releases_url":"https://api.github.com/repos/DemocracyEarth/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/DemocracyEarth/contracts/deployments","created_at":"2017-07-29T23:01:42Z","updated_at":"2018-04-15T21:43:48Z","pushed_at":"2018-04-17T16:02:25Z","git_url":"git://github.com/DemocracyEarth/contracts.git","ssh_url":"git@github.com:DemocracyEarth/contracts.git","clone_url":"https://github.com/DemocracyEarth/contracts.git","svn_url":"https://github.com/DemocracyEarth/contracts","homepage":"","size":23869,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":1,"open_issues":13,"watchers":9,"default_branch":"master"}},"base":{"label":"DemocracyEarth:master","ref":"master","sha":"bf174a82f15273991f543dfa97ea5123d52c0bb8","user":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"repo":{"id":98763038,"name":"contracts","full_name":"DemocracyEarth/contracts","owner":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DemocracyEarth/contracts","description":"The social smart contract implementation","fork":false,"url":"https://api.github.com/repos/DemocracyEarth/contracts","forks_url":"https://api.github.com/repos/DemocracyEarth/contracts/forks","keys_url":"https://api.github.com/repos/DemocracyEarth/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemocracyEarth/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemocracyEarth/contracts/teams","hooks_url":"https://api.github.com/repos/DemocracyEarth/contracts/hooks","issue_events_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/DemocracyEarth/contracts/events","assignees_url":"https://api.github.com/repos/DemocracyEarth/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/DemocracyEarth/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/tags","blobs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/DemocracyEarth/contracts/languages","stargazers_url":"https://api.github.com/repos/DemocracyEarth/contracts/stargazers","contributors_url":"https://api.github.com/repos/DemocracyEarth/contracts/contributors","subscribers_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscribers","subscription_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscription","commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemocracyEarth/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/DemocracyEarth/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemocracyEarth/contracts/merges","archive_url":"https://api.github.com/repos/DemocracyEarth/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemocracyEarth/contracts/downloads","issues_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/DemocracyEarth/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/DemocracyEarth/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemocracyEarth/contracts/labels{/name}","releases_url":"https://api.github.com/repos/DemocracyEarth/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/DemocracyEarth/contracts/deployments","created_at":"2017-07-29T23:01:42Z","updated_at":"2018-04-15T21:43:48Z","pushed_at":"2018-04-17T16:02:25Z","git_url":"git://github.com/DemocracyEarth/contracts.git","ssh_url":"git@github.com:DemocracyEarth/contracts.git","clone_url":"https://github.com/DemocracyEarth/contracts.git","svn_url":"https://github.com/DemocracyEarth/contracts","homepage":"","size":23869,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":1,"open_issues":13,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21"},"html":{"href":"https://github.com/DemocracyEarth/contracts/pull/21"},"issue":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21"},"comments":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/76befc1bed97167835cb8d3b8102985b752d4d07"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"aecc"}}