{"action":"created","comment":{"url":"https://api.github.com/repos/zcash/zcash/pulls/comments/77518151","id":77518151,"diff_hunk":"@@ -33,29 +33,21 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul\n             blockindex = chainActive.Tip();\n     }\n \n-    uint32_t powLimit =\n-        UintToArith256(Params().GetConsensus().powLimit).GetCompact();;\n-    {\n-        if (networkDifficulty && Params().GetConsensus().fPowAllowMinDifficultyBlocks)\n-        {\n-            // Special difficulty rule for testnet:\n-            // If a block's timestamp is more than 2*nPowTargetSpacing minutes after\n-            // the previous block, then it is permitted to be min-difficulty. So\n-            // get the last non-min-difficulty (or at worst the genesis difficulty).\n-            auto window = Params().GetConsensus().nPowTargetSpacing*2;\n-            while (blockindex->pprev && blockindex->nBits == powLimit &&\n-                    blockindex->GetBlockTime() > blockindex->pprev->GetBlockTime() + window) {\n-                blockindex = blockindex->pprev;\n-            }\n-        }\n+    uint32_t bits;\n+    if (networkDifficulty) {\n+        bits = GetNextWorkRequired(blockindex, nullptr, Params().GetConsensus());\n+    } else {\n+        bits = blockindex->nBits;\n     }\n \n-    int nShift = (blockindex->nBits >> 24) & 0xff;\n+    uint32_t powLimit =\n+        UintToArith256(Params().GetConsensus().powLimit).GetCompact();;","path":"src/rpcblockchain.cpp","position":28,"original_position":28,"commit_id":"333ea3c4266179da5d40e496ae60bcce0259c790","original_commit_id":"333ea3c4266179da5d40e496ae60bcce0259c790","user":{"login":"daira","id":643204,"avatar_url":"https://avatars.githubusercontent.com/u/643204?v=3","gravatar_id":"","url":"https://api.github.com/users/daira","html_url":"https://github.com/daira","followers_url":"https://api.github.com/users/daira/followers","following_url":"https://api.github.com/users/daira/following{/other_user}","gists_url":"https://api.github.com/users/daira/gists{/gist_id}","starred_url":"https://api.github.com/users/daira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daira/subscriptions","organizations_url":"https://api.github.com/users/daira/orgs","repos_url":"https://api.github.com/users/daira/repos","events_url":"https://api.github.com/users/daira/events{/privacy}","received_events_url":"https://api.github.com/users/daira/received_events","type":"User","site_admin":false},"body":"Double \";\". (Harmless but odd.)","created_at":"2016-09-05T12:58:37Z","updated_at":"2016-09-05T12:58:37Z","html_url":"https://github.com/zcash/zcash/pull/1338#discussion_r77518151","pull_request_url":"https://api.github.com/repos/zcash/zcash/pulls/1338","_links":{"self":{"href":"https://api.github.com/repos/zcash/zcash/pulls/comments/77518151"},"html":{"href":"https://github.com/zcash/zcash/pull/1338#discussion_r77518151"},"pull_request":{"href":"https://api.github.com/repos/zcash/zcash/pulls/1338"}}},"pull_request":{"url":"https://api.github.com/repos/zcash/zcash/pulls/1338","id":83987700,"html_url":"https://github.com/zcash/zcash/pull/1338","diff_url":"https://github.com/zcash/zcash/pull/1338.diff","patch_url":"https://github.com/zcash/zcash/pull/1338.patch","issue_url":"https://api.github.com/repos/zcash/zcash/issues/1338","number":1338,"state":"open","locked":false,"title":"Tweaks to difficulty adjustment algorithm","user":{"login":"str4d","id":4993799,"avatar_url":"https://avatars.githubusercontent.com/u/4993799?v=3","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"body":"This PR changes the difficulty algorithm to adjust from the average difficulty over the\r\nblock window instead of from the last difficulty. It also removes the special rules for the\r\ntestnet, which are incompatible with difficulty averaging.\r\n\r\nCloses #147 again.","created_at":"2016-09-05T11:21:45Z","updated_at":"2016-09-05T12:58:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d6c7f2337735d3385d296d5068920c45c137a58","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/zcash/zcash/milestones/28","html_url":"https://github.com/zcash/zcash/milestones/Beta%201%20-%20complete%20RPC","labels_url":"https://api.github.com/repos/zcash/zcash/milestones/28/labels","id":1670695,"number":28,"title":"Beta 1 - complete RPC","description":"","creator":{"login":"nathan-at-least","id":4369700,"avatar_url":"https://avatars.githubusercontent.com/u/4369700?v=3","gravatar_id":"","url":"https://api.github.com/users/nathan-at-least","html_url":"https://github.com/nathan-at-least","followers_url":"https://api.github.com/users/nathan-at-least/followers","following_url":"https://api.github.com/users/nathan-at-least/following{/other_user}","gists_url":"https://api.github.com/users/nathan-at-least/gists{/gist_id}","starred_url":"https://api.github.com/users/nathan-at-least/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathan-at-least/subscriptions","organizations_url":"https://api.github.com/users/nathan-at-least/orgs","repos_url":"https://api.github.com/users/nathan-at-least/repos","events_url":"https://api.github.com/users/nathan-at-least/events{/privacy}","received_events_url":"https://api.github.com/users/nathan-at-least/received_events","type":"User","site_admin":false},"open_issues":29,"closed_issues":26,"state":"open","created_at":"2016-03-28T23:11:04Z","updated_at":"2016-09-05T11:21:45Z","due_on":"2016-09-06T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/zcash/zcash/pulls/1338/commits","review_comments_url":"https://api.github.com/repos/zcash/zcash/pulls/1338/comments","review_comment_url":"https://api.github.com/repos/zcash/zcash/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zcash/zcash/issues/1338/comments","statuses_url":"https://api.github.com/repos/zcash/zcash/statuses/333ea3c4266179da5d40e496ae60bcce0259c790","head":{"label":"str4d:147-tweak-difficulty-adjustment-algorithm","ref":"147-tweak-difficulty-adjustment-algorithm","sha":"333ea3c4266179da5d40e496ae60bcce0259c790","user":{"login":"str4d","id":4993799,"avatar_url":"https://avatars.githubusercontent.com/u/4993799?v=3","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"repo":{"id":52462432,"name":"zcash","full_name":"str4d/zcash","owner":{"login":"str4d","id":4993799,"avatar_url":"https://avatars.githubusercontent.com/u/4993799?v=3","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/str4d/zcash","description":"zcash","fork":true,"url":"https://api.github.com/repos/str4d/zcash","forks_url":"https://api.github.com/repos/str4d/zcash/forks","keys_url":"https://api.github.com/repos/str4d/zcash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/str4d/zcash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/str4d/zcash/teams","hooks_url":"https://api.github.com/repos/str4d/zcash/hooks","issue_events_url":"https://api.github.com/repos/str4d/zcash/issues/events{/number}","events_url":"https://api.github.com/repos/str4d/zcash/events","assignees_url":"https://api.github.com/repos/str4d/zcash/assignees{/user}","branches_url":"https://api.github.com/repos/str4d/zcash/branches{/branch}","tags_url":"https://api.github.com/repos/str4d/zcash/tags","blobs_url":"https://api.github.com/repos/str4d/zcash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/str4d/zcash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/str4d/zcash/git/refs{/sha}","trees_url":"https://api.github.com/repos/str4d/zcash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/str4d/zcash/statuses/{sha}","languages_url":"https://api.github.com/repos/str4d/zcash/languages","stargazers_url":"https://api.github.com/repos/str4d/zcash/stargazers","contributors_url":"https://api.github.com/repos/str4d/zcash/contributors","subscribers_url":"https://api.github.com/repos/str4d/zcash/subscribers","subscription_url":"https://api.github.com/repos/str4d/zcash/subscription","commits_url":"https://api.github.com/repos/str4d/zcash/commits{/sha}","git_commits_url":"https://api.github.com/repos/str4d/zcash/git/commits{/sha}","comments_url":"https://api.github.com/repos/str4d/zcash/comments{/number}","issue_comment_url":"https://api.github.com/repos/str4d/zcash/issues/comments{/number}","contents_url":"https://api.github.com/repos/str4d/zcash/contents/{+path}","compare_url":"https://api.github.com/repos/str4d/zcash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/str4d/zcash/merges","archive_url":"https://api.github.com/repos/str4d/zcash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/str4d/zcash/downloads","issues_url":"https://api.github.com/repos/str4d/zcash/issues{/number}","pulls_url":"https://api.github.com/repos/str4d/zcash/pulls{/number}","milestones_url":"https://api.github.com/repos/str4d/zcash/milestones{/number}","notifications_url":"https://api.github.com/repos/str4d/zcash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/str4d/zcash/labels{/name}","releases_url":"https://api.github.com/repos/str4d/zcash/releases{/id}","deployments_url":"https://api.github.com/repos/str4d/zcash/deployments","created_at":"2016-02-24T17:50:40Z","updated_at":"2016-09-01T12:28:09Z","pushed_at":"2016-09-05T11:20:07Z","git_url":"git://github.com/str4d/zcash.git","ssh_url":"git@github.com:str4d/zcash.git","clone_url":"https://github.com/str4d/zcash.git","svn_url":"https://github.com/str4d/zcash","homepage":"https://z.cash/","size":43303,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":5,"default_branch":"zc.v0.11.2.latest"}},"base":{"label":"zcash:zc.v0.11.2.latest","ref":"zc.v0.11.2.latest","sha":"b181f7032b2e5416d8ee7efab09cf4f6c2322a81","user":{"login":"zcash","id":16122764,"avatar_url":"https://avatars.githubusercontent.com/u/16122764?v=3","gravatar_id":"","url":"https://api.github.com/users/zcash","html_url":"https://github.com/zcash","followers_url":"https://api.github.com/users/zcash/followers","following_url":"https://api.github.com/users/zcash/following{/other_user}","gists_url":"https://api.github.com/users/zcash/gists{/gist_id}","starred_url":"https://api.github.com/users/zcash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcash/subscriptions","organizations_url":"https://api.github.com/users/zcash/orgs","repos_url":"https://api.github.com/users/zcash/repos","events_url":"https://api.github.com/users/zcash/events{/privacy}","received_events_url":"https://api.github.com/users/zcash/received_events","type":"Organization","site_admin":false},"repo":{"id":26987049,"name":"zcash","full_name":"zcash/zcash","owner":{"login":"zcash","id":16122764,"avatar_url":"https://avatars.githubusercontent.com/u/16122764?v=3","gravatar_id":"","url":"https://api.github.com/users/zcash","html_url":"https://github.com/zcash","followers_url":"https://api.github.com/users/zcash/followers","following_url":"https://api.github.com/users/zcash/following{/other_user}","gists_url":"https://api.github.com/users/zcash/gists{/gist_id}","starred_url":"https://api.github.com/users/zcash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcash/subscriptions","organizations_url":"https://api.github.com/users/zcash/orgs","repos_url":"https://api.github.com/users/zcash/repos","events_url":"https://api.github.com/users/zcash/events{/privacy}","received_events_url":"https://api.github.com/users/zcash/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zcash/zcash","description":"zcash","fork":false,"url":"https://api.github.com/repos/zcash/zcash","forks_url":"https://api.github.com/repos/zcash/zcash/forks","keys_url":"https://api.github.com/repos/zcash/zcash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zcash/zcash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zcash/zcash/teams","hooks_url":"https://api.github.com/repos/zcash/zcash/hooks","issue_events_url":"https://api.github.com/repos/zcash/zcash/issues/events{/number}","events_url":"https://api.github.com/repos/zcash/zcash/events","assignees_url":"https://api.github.com/repos/zcash/zcash/assignees{/user}","branches_url":"https://api.github.com/repos/zcash/zcash/branches{/branch}","tags_url":"https://api.github.com/repos/zcash/zcash/tags","blobs_url":"https://api.github.com/repos/zcash/zcash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zcash/zcash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zcash/zcash/git/refs{/sha}","trees_url":"https://api.github.com/repos/zcash/zcash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zcash/zcash/statuses/{sha}","languages_url":"https://api.github.com/repos/zcash/zcash/languages","stargazers_url":"https://api.github.com/repos/zcash/zcash/stargazers","contributors_url":"https://api.github.com/repos/zcash/zcash/contributors","subscribers_url":"https://api.github.com/repos/zcash/zcash/subscribers","subscription_url":"https://api.github.com/repos/zcash/zcash/subscription","commits_url":"https://api.github.com/repos/zcash/zcash/commits{/sha}","git_commits_url":"https://api.github.com/repos/zcash/zcash/git/commits{/sha}","comments_url":"https://api.github.com/repos/zcash/zcash/comments{/number}","issue_comment_url":"https://api.github.com/repos/zcash/zcash/issues/comments{/number}","contents_url":"https://api.github.com/repos/zcash/zcash/contents/{+path}","compare_url":"https://api.github.com/repos/zcash/zcash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zcash/zcash/merges","archive_url":"https://api.github.com/repos/zcash/zcash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zcash/zcash/downloads","issues_url":"https://api.github.com/repos/zcash/zcash/issues{/number}","pulls_url":"https://api.github.com/repos/zcash/zcash/pulls{/number}","milestones_url":"https://api.github.com/repos/zcash/zcash/milestones{/number}","notifications_url":"https://api.github.com/repos/zcash/zcash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zcash/zcash/labels{/name}","releases_url":"https://api.github.com/repos/zcash/zcash/releases{/id}","deployments_url":"https://api.github.com/repos/zcash/zcash/deployments","created_at":"2014-11-22T03:13:10Z","updated_at":"2016-09-05T07:24:40Z","pushed_at":"2016-09-05T11:21:46Z","git_url":"git://github.com/zcash/zcash.git","ssh_url":"git@github.com:zcash/zcash.git","clone_url":"https://github.com/zcash/zcash.git","svn_url":"https://github.com/zcash/zcash","homepage":"https://z.cash/","size":49620,"stargazers_count":933,"watchers_count":933,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":106,"mirror_url":null,"open_issues_count":385,"forks":106,"open_issues":385,"watchers":933,"default_branch":"zc.v0.11.2.latest"}},"_links":{"self":{"href":"https://api.github.com/repos/zcash/zcash/pulls/1338"},"html":{"href":"https://github.com/zcash/zcash/pull/1338"},"issue":{"href":"https://api.github.com/repos/zcash/zcash/issues/1338"},"comments":{"href":"https://api.github.com/repos/zcash/zcash/issues/1338/comments"},"review_comments":{"href":"https://api.github.com/repos/zcash/zcash/pulls/1338/comments"},"review_comment":{"href":"https://api.github.com/repos/zcash/zcash/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zcash/zcash/pulls/1338/commits"},"statuses":{"href":"https://api.github.com/repos/zcash/zcash/statuses/333ea3c4266179da5d40e496ae60bcce0259c790"}}}}
{"actor":{"display_login":"daira"}}