{"action":"created","comment":{"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments/184952206","pull_request_review_id":116245483,"id":184952206,"diff_hunk":"@@ -70,63 +68,58 @@ public static uint256 BlockMerkleRoot(Block block, out bool mutated)\n         /// <param name=\"mutated\"><c>true</c> if at least one leaf of the merkle tree has the same hash as any subtree. Otherwise: <c>false</c>.</param>\n         public static uint256 ComputeMerkleRoot(List<uint256> leaves, out bool mutated)\n         {\n-            var branch = new List<uint256>();\n-\n             mutated = false;\n-            if (leaves.Count == 0)\n-                return uint256.Zero;\n+            if (leaves.Count == 0) return uint256.Zero;\n \n-            // count is the number of leaves processed so far.\n-            uint count = 0;\n+            var branch = new List<uint256>();\n \n-            // inner is an array of eagerly computed subtree hashes, indexed by tree\n+            // subTreeHashes is an array of eagerly computed subtree hashes, indexed by tree\n             // level (0 being the leaves).\n-            // For example, when count is 25 (11001 in binary), inner[4] is the hash of\n-            // the first 16 leaves, inner[3] of the next 8 leaves, and inner[0] equal to\n-            // the last leaf. The other inner entries are undefined.\n-            var inner = new uint256[32];\n+            // For example, when count is 25 (11001 in binary), subTreeHashes[4] is the hash of\n+            // the first 16 leaves, subTreeHashes[3] of the next 8 leaves, and subTreeHashes[0] equal to\n+            // the last leaf. The other subTreeHashes entries are undefined.\n+            var subTreeHashes = new uint256[32];\n \n-            for (int i = 0; i < inner.Length; i++)\n-                inner[i] = uint256.Zero;\n+            for (int i = 0; i < subTreeHashes.Length; i++)\n+                subTreeHashes[i] = uint256.Zero;\n \n             // Which position in inner is a hash that depends on the matching leaf.\n             int matchLevel = -1;\n+            uint processedLeavesCount = 0;\n \n-            // First process all leaves into 'inner' values.\n-            while (count < leaves.Count)\n+            // First process all leaves into subTreeHashes values.\n+            while (processedLeavesCount < leaves.Count)\n             {\n-                uint256 h = leaves[(int)count];\n+                uint256 currentLeaveHash = leaves[(int)processedLeavesCount];\n                 bool match = false;\n-                count++;\n+                processedLeavesCount++;\n                 int level;\n \n-                // For each of the lower bits in count that are 0, do 1 step. Each\n-                // corresponds to an inner value that existed before processing the\n+                // For each of the lower bits in processedLeavesCount that are 0, do 1 step. Each\n+                // corresponds to an subTreeHash value that existed before processing the\n                 // current leaf, and each needs a hash to combine it.\n-                for (level = 0; (count & (((uint)1) << level)) == 0; level++)\n+                for ( level = 0; (processedLeavesCount & (((uint)1) << level)) == 0; level++)\n+                //for (level = 0; (processedLeavesCount % ((2^level) -1)) == 0; level++)","path":"src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/BlockMerkleRootRule.cs","position":92,"original_position":92,"commit_id":"77edb8f88aada23af3787faf930059aefb2bafd4","original_commit_id":"9bcad467130cfc951ef7edb585bd035a918eaa5d","user":{"login":"Aprogiena","id":30052221,"avatar_url":"https://avatars0.githubusercontent.com/u/30052221?v=4","gravatar_id":"","url":"https://api.github.com/users/Aprogiena","html_url":"https://github.com/Aprogiena","followers_url":"https://api.github.com/users/Aprogiena/followers","following_url":"https://api.github.com/users/Aprogiena/following{/other_user}","gists_url":"https://api.github.com/users/Aprogiena/gists{/gist_id}","starred_url":"https://api.github.com/users/Aprogiena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aprogiena/subscriptions","organizations_url":"https://api.github.com/users/Aprogiena/orgs","repos_url":"https://api.github.com/users/Aprogiena/repos","events_url":"https://api.github.com/users/Aprogiena/events{/privacy}","received_events_url":"https://api.github.com/users/Aprogiena/received_events","type":"User","site_admin":false},"body":"if something is not clear, make a normal comment instead","created_at":"2018-04-30T10:19:30Z","updated_at":"2018-04-30T10:19:30Z","html_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353#discussion_r184952206","pull_request_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments/184952206"},"html":{"href":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353#discussion_r184952206"},"pull_request":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353"}},"in_reply_to_id":184892527},"pull_request":{"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353","id":184778549,"html_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353","diff_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353.diff","patch_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353.patch","issue_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/1353","number":1353,"state":"open","locked":false,"title":"Ban peers sending blocks with duplicate transactions","user":{"login":"monsieurleberre","id":4638821,"avatar_url":"https://avatars2.githubusercontent.com/u/4638821?v=4","gravatar_id":"","url":"https://api.github.com/users/monsieurleberre","html_url":"https://github.com/monsieurleberre","followers_url":"https://api.github.com/users/monsieurleberre/followers","following_url":"https://api.github.com/users/monsieurleberre/following{/other_user}","gists_url":"https://api.github.com/users/monsieurleberre/gists{/gist_id}","starred_url":"https://api.github.com/users/monsieurleberre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monsieurleberre/subscriptions","organizations_url":"https://api.github.com/users/monsieurleberre/orgs","repos_url":"https://api.github.com/users/monsieurleberre/repos","events_url":"https://api.github.com/users/monsieurleberre/events{/privacy}","received_events_url":"https://api.github.com/users/monsieurleberre/received_events","type":"User","site_admin":false},"body":"trying to solve the issues raised in\r\nhttps://github.com/stratisproject/StratisBitcoinFullNode/issues/1278\r\n\r\nI think some of the previous unit tests were using a whitelisted peer where it should have been a normal one, making it less relevant, so I changed it, please let me know if that is a mistake\r\n\r\nthere is still the issue mentioned at the end by @noescape00 for blocks below the last checkpoint","created_at":"2018-04-28T10:30:51Z","updated_at":"2018-04-30T10:19:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eaf4409491bff6b236894d54dc0bd9275c5f2238","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353/commits","review_comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353/comments","review_comment_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/1353/comments","statuses_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/77edb8f88aada23af3787faf930059aefb2bafd4","head":{"label":"monsieurleberre:duplicate-transaction","ref":"duplicate-transaction","sha":"77edb8f88aada23af3787faf930059aefb2bafd4","user":{"login":"monsieurleberre","id":4638821,"avatar_url":"https://avatars2.githubusercontent.com/u/4638821?v=4","gravatar_id":"","url":"https://api.github.com/users/monsieurleberre","html_url":"https://github.com/monsieurleberre","followers_url":"https://api.github.com/users/monsieurleberre/followers","following_url":"https://api.github.com/users/monsieurleberre/following{/other_user}","gists_url":"https://api.github.com/users/monsieurleberre/gists{/gist_id}","starred_url":"https://api.github.com/users/monsieurleberre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monsieurleberre/subscriptions","organizations_url":"https://api.github.com/users/monsieurleberre/orgs","repos_url":"https://api.github.com/users/monsieurleberre/repos","events_url":"https://api.github.com/users/monsieurleberre/events{/privacy}","received_events_url":"https://api.github.com/users/monsieurleberre/received_events","type":"User","site_admin":false},"repo":{"id":124098915,"name":"StratisBitcoinFullNode","full_name":"monsieurleberre/StratisBitcoinFullNode","owner":{"login":"monsieurleberre","id":4638821,"avatar_url":"https://avatars2.githubusercontent.com/u/4638821?v=4","gravatar_id":"","url":"https://api.github.com/users/monsieurleberre","html_url":"https://github.com/monsieurleberre","followers_url":"https://api.github.com/users/monsieurleberre/followers","following_url":"https://api.github.com/users/monsieurleberre/following{/other_user}","gists_url":"https://api.github.com/users/monsieurleberre/gists{/gist_id}","starred_url":"https://api.github.com/users/monsieurleberre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monsieurleberre/subscriptions","organizations_url":"https://api.github.com/users/monsieurleberre/orgs","repos_url":"https://api.github.com/users/monsieurleberre/repos","events_url":"https://api.github.com/users/monsieurleberre/events{/privacy}","received_events_url":"https://api.github.com/users/monsieurleberre/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monsieurleberre/StratisBitcoinFullNode","description":"Bitcoin full node in C#","fork":true,"url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode","forks_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/forks","keys_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/teams","hooks_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/hooks","issue_events_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/issues/events{/number}","events_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/events","assignees_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/assignees{/user}","branches_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/branches{/branch}","tags_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/tags","blobs_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/git/refs{/sha}","trees_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/statuses/{sha}","languages_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/languages","stargazers_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/stargazers","contributors_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/contributors","subscribers_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/subscribers","subscription_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/subscription","commits_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/commits{/sha}","git_commits_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/git/commits{/sha}","comments_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/comments{/number}","issue_comment_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/issues/comments{/number}","contents_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/contents/{+path}","compare_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/merges","archive_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/downloads","issues_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/issues{/number}","pulls_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/pulls{/number}","milestones_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/milestones{/number}","notifications_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/labels{/name}","releases_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/releases{/id}","deployments_url":"https://api.github.com/repos/monsieurleberre/StratisBitcoinFullNode/deployments","created_at":"2018-03-06T15:32:11Z","updated_at":"2018-04-25T14:58:27Z","pushed_at":"2018-04-30T08:52:11Z","git_url":"git://github.com/monsieurleberre/StratisBitcoinFullNode.git","ssh_url":"git@github.com:monsieurleberre/StratisBitcoinFullNode.git","clone_url":"https://github.com/monsieurleberre/StratisBitcoinFullNode.git","svn_url":"https://github.com/monsieurleberre/StratisBitcoinFullNode","homepage":"https://stratisplatform.com","size":10759,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"stratisproject:master","ref":"master","sha":"d5b8bd73b7dd914e098d54142d94fac65dd55208","user":{"login":"stratisproject","id":15229748,"avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"repo":{"id":67271290,"name":"StratisBitcoinFullNode","full_name":"stratisproject/StratisBitcoinFullNode","owner":{"login":"stratisproject","id":15229748,"avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stratisproject/StratisBitcoinFullNode","description":"Bitcoin full node in C#","fork":false,"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode","forks_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/forks","keys_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/teams","hooks_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/hooks","issue_events_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/events{/number}","events_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/events","assignees_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/assignees{/user}","branches_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/branches{/branch}","tags_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/tags","blobs_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/refs{/sha}","trees_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/{sha}","languages_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/languages","stargazers_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/stargazers","contributors_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/contributors","subscribers_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/subscribers","subscription_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/subscription","commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/commits{/sha}","git_commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/commits{/sha}","comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/comments{/number}","issue_comment_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/comments{/number}","contents_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/contents/{+path}","compare_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/merges","archive_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/downloads","issues_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues{/number}","pulls_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls{/number}","milestones_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/milestones{/number}","notifications_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/labels{/name}","releases_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/releases{/id}","deployments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/deployments","created_at":"2016-09-03T04:32:51Z","updated_at":"2018-04-30T09:06:10Z","pushed_at":"2018-04-30T09:26:52Z","git_url":"git://github.com/stratisproject/StratisBitcoinFullNode.git","ssh_url":"git@github.com:stratisproject/StratisBitcoinFullNode.git","clone_url":"https://github.com/stratisproject/StratisBitcoinFullNode.git","svn_url":"https://github.com/stratisproject/StratisBitcoinFullNode","homepage":"https://stratisplatform.com","size":10689,"stargazers_count":449,"watchers_count":449,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":187,"mirror_url":null,"archived":false,"open_issues_count":101,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":187,"open_issues":101,"watchers":449,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353"},"html":{"href":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/1353"},"issue":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/1353"},"comments":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/1353/comments"},"review_comments":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353/comments"},"review_comment":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/1353/commits"},"statuses":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/77edb8f88aada23af3787faf930059aefb2bafd4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Aprogiena"}}