{"action":"created","comment":{"url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/comments/235428405","pull_request_review_id":177278670,"id":235428405,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTQyODQwNQ==","diff_hunk":"@@ -0,0 +1,215 @@\n+// Copyright 2018 Google Inc. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package races\n+\n+import (\n+\t\"context\"\n+\t\"errors\"\n+\t\"math/rand\"\n+\t\"reflect\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\tct \"github.com/google/certificate-transparency-go\"\n+\t\"github.com/google/certificate-transparency-go/ctpolicy\"\n+)\n+\n+const (\n+\t// URLProtocol keeps protocol substring for Log URLs.\n+\tURLProtocol = \"https://\"\n+\n+\t// Sleeptim is duration between parallel batch call and subsequent requests to Logs within group.\n+\tSleepTime = time.Second\n+)\n+\n+type guardedLogs struct {\n+\tlogURLs map[string]bool\n+\tm       sync.RWMutex\n+}\n+\n+func (gList *guardedLogs) add(logURL string) {\n+\tgList.m.Lock()\n+\tgList.logURLs[logURL] = true\n+\tgList.m.Unlock()\n+}\n+\n+func (gList *guardedLogs) has(logURL string) bool {\n+\tgList.m.RLock()\n+\texist := gList.logURLs[logURL]\n+\tgList.m.RUnlock()\n+\treturn exist\n+}\n+\n+func (gList *guardedLogs) sumFor(URLs map[string]bool) int {\n+\tvar entries int\n+\tgList.m.RLock()\n+\tfor url := range URLs {\n+\t\tif gList.logURLs[url] {\n+\t\t\tentries++\n+\t\t}\n+\t}\n+\tgList.m.RUnlock()\n+\treturn entries\n+}\n+\n+type result struct {\n+\tsct    *ct.SignedCertificateTimestamp\n+\tlogURL string\n+\terr    error\n+}\n+\n+func max(a, b int) int {\n+\tif a > b {\n+\t\treturn a\n+\t}\n+\treturn b\n+}\n+\n+// sleepTime calculates duration for consequent call. For first paralleStart calls duration is 0, while every next one gets additional dur interval.\n+func sleepTime(idx int, parallelStart int, dur time.Duration) time.Duration {\n+\treturn (time.Duration(max(idx+1-parallelStart, 0)) * dur)\n+}\n+\n+// Submitter is interface wrapping Log-request-response cycle and any processing.\n+type Submitter interface {\n+\tSubmitToSingleCTWithResult(ctx context.Context, logURL string, chain []ct.ASN1Cert) (*ct.SignedCertificateTimestamp, error)\n+}\n+\n+func groupRace(ctx context.Context, chain []ct.ASN1Cert, group *ctpolicy.LogGroupInfo, parallelStart int,\n+\tresults chan result, requestList *guardedLogs, sctList *guardedLogs, submitter Submitter) {\n+\tgroupURLs := reflect.ValueOf(group.LogURLs).MapKeys()\n+\tfor i, urlNum := range rand.Perm(len(groupURLs)) {","path":"submission/races.go","position":93,"original_position":93,"commit_id":"18a563070e3248aa60ea493918ddefc557bddd83","original_commit_id":"1aa5b00a79f97d7a0de06f4b4b01d74983284275","user":{"login":"daviddrysdale","id":457208,"node_id":"MDQ6VXNlcjQ1NzIwOA==","avatar_url":"https://avatars3.githubusercontent.com/u/457208?v=4","gravatar_id":"","url":"https://api.github.com/users/daviddrysdale","html_url":"https://github.com/daviddrysdale","followers_url":"https://api.github.com/users/daviddrysdale/followers","following_url":"https://api.github.com/users/daviddrysdale/following{/other_user}","gists_url":"https://api.github.com/users/daviddrysdale/gists{/gist_id}","starred_url":"https://api.github.com/users/daviddrysdale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daviddrysdale/subscriptions","organizations_url":"https://api.github.com/users/daviddrysdale/orgs","repos_url":"https://api.github.com/users/daviddrysdale/repos","events_url":"https://api.github.com/users/daviddrysdale/events{/privacy}","received_events_url":"https://api.github.com/users/daviddrysdale/received_events","type":"User","site_admin":false},"body":"If you're spinning up parallel goroutines for the N URLs, is the `rand.Perm` necessary?","created_at":"2018-11-21T15:19:27Z","updated_at":"2018-11-21T15:54:46Z","html_url":"https://github.com/google/certificate-transparency-go/pull/405#discussion_r235428405","pull_request_url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/comments/235428405"},"html":{"href":"https://github.com/google/certificate-transparency-go/pull/405#discussion_r235428405"},"pull_request":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405"}}},"pull_request":{"url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405","id":232667224,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyNjY3MjI0","html_url":"https://github.com/google/certificate-transparency-go/pull/405","diff_url":"https://github.com/google/certificate-transparency-go/pull/405.diff","patch_url":"https://github.com/google/certificate-transparency-go/pull/405.patch","issue_url":"https://api.github.com/repos/google/certificate-transparency-go/issues/405","number":405,"state":"open","locked":false,"title":"Submission logic base.","user":{"login":"Mercurrent","id":1265448,"node_id":"MDQ6VXNlcjEyNjU0NDg=","avatar_url":"https://avatars0.githubusercontent.com/u/1265448?v=4","gravatar_id":"","url":"https://api.github.com/users/Mercurrent","html_url":"https://github.com/Mercurrent","followers_url":"https://api.github.com/users/Mercurrent/followers","following_url":"https://api.github.com/users/Mercurrent/following{/other_user}","gists_url":"https://api.github.com/users/Mercurrent/gists{/gist_id}","starred_url":"https://api.github.com/users/Mercurrent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mercurrent/subscriptions","organizations_url":"https://api.github.com/users/Mercurrent/orgs","repos_url":"https://api.github.com/users/Mercurrent/repos","events_url":"https://api.github.com/users/Mercurrent/events{/privacy}","received_events_url":"https://api.github.com/users/Mercurrent/received_events","type":"User","site_admin":false},"body":"I refrained from adding more tests until we agree on basic logic.\r\n\r\nLet's see if comment mention notifies @jdkasten","created_at":"2018-11-21T13:40:23Z","updated_at":"2018-11-21T15:54:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cfb15caa693aafc9db5b22d57b38fd159f26ae4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":602120732,"node_id":"MDU6TGFiZWw2MDIxMjA3MzI=","url":"https://api.github.com/repos/google/certificate-transparency-go/labels/cla:%20yes","name":"cla: yes","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405/commits","review_comments_url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405/comments","review_comment_url":"https://api.github.com/repos/google/certificate-transparency-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/certificate-transparency-go/issues/405/comments","statuses_url":"https://api.github.com/repos/google/certificate-transparency-go/statuses/18a563070e3248aa60ea493918ddefc557bddd83","head":{"label":"Mercurrent:submission-races","ref":"submission-races","sha":"18a563070e3248aa60ea493918ddefc557bddd83","user":{"login":"Mercurrent","id":1265448,"node_id":"MDQ6VXNlcjEyNjU0NDg=","avatar_url":"https://avatars0.githubusercontent.com/u/1265448?v=4","gravatar_id":"","url":"https://api.github.com/users/Mercurrent","html_url":"https://github.com/Mercurrent","followers_url":"https://api.github.com/users/Mercurrent/followers","following_url":"https://api.github.com/users/Mercurrent/following{/other_user}","gists_url":"https://api.github.com/users/Mercurrent/gists{/gist_id}","starred_url":"https://api.github.com/users/Mercurrent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mercurrent/subscriptions","organizations_url":"https://api.github.com/users/Mercurrent/orgs","repos_url":"https://api.github.com/users/Mercurrent/repos","events_url":"https://api.github.com/users/Mercurrent/events{/privacy}","received_events_url":"https://api.github.com/users/Mercurrent/received_events","type":"User","site_admin":false},"repo":{"id":148490410,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg0OTA0MTA=","name":"certificate-transparency-go","full_name":"Mercurrent/certificate-transparency-go","private":false,"owner":{"login":"Mercurrent","id":1265448,"node_id":"MDQ6VXNlcjEyNjU0NDg=","avatar_url":"https://avatars0.githubusercontent.com/u/1265448?v=4","gravatar_id":"","url":"https://api.github.com/users/Mercurrent","html_url":"https://github.com/Mercurrent","followers_url":"https://api.github.com/users/Mercurrent/followers","following_url":"https://api.github.com/users/Mercurrent/following{/other_user}","gists_url":"https://api.github.com/users/Mercurrent/gists{/gist_id}","starred_url":"https://api.github.com/users/Mercurrent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mercurrent/subscriptions","organizations_url":"https://api.github.com/users/Mercurrent/orgs","repos_url":"https://api.github.com/users/Mercurrent/repos","events_url":"https://api.github.com/users/Mercurrent/events{/privacy}","received_events_url":"https://api.github.com/users/Mercurrent/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Mercurrent/certificate-transparency-go","description":"Auditing for TLS certificates, Go code. ","fork":true,"url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go","forks_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/forks","keys_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/teams","hooks_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/hooks","issue_events_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/issues/events{/number}","events_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/events","assignees_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/assignees{/user}","branches_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/branches{/branch}","tags_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/tags","blobs_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/statuses/{sha}","languages_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/languages","stargazers_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/stargazers","contributors_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/contributors","subscribers_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/subscribers","subscription_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/subscription","commits_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/contents/{+path}","compare_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/merges","archive_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/downloads","issues_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/issues{/number}","pulls_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/pulls{/number}","milestones_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/milestones{/number}","notifications_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/labels{/name}","releases_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/releases{/id}","deployments_url":"https://api.github.com/repos/Mercurrent/certificate-transparency-go/deployments","created_at":"2018-09-12T14:06:36Z","updated_at":"2018-09-12T14:06:39Z","pushed_at":"2018-11-21T15:38:50Z","git_url":"git://github.com/Mercurrent/certificate-transparency-go.git","ssh_url":"git@github.com:Mercurrent/certificate-transparency-go.git","clone_url":"https://github.com/Mercurrent/certificate-transparency-go.git","svn_url":"https://github.com/Mercurrent/certificate-transparency-go","homepage":"http://www.certificate-transparency.org/","size":8107,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"3312f9393dac15d24b1322a0bceedee2e9de7b78","user":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":90636971,"node_id":"MDEwOlJlcG9zaXRvcnk5MDYzNjk3MQ==","name":"certificate-transparency-go","full_name":"google/certificate-transparency-go","private":false,"owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/google/certificate-transparency-go","description":"Auditing for TLS certificates, Go code. ","fork":false,"url":"https://api.github.com/repos/google/certificate-transparency-go","forks_url":"https://api.github.com/repos/google/certificate-transparency-go/forks","keys_url":"https://api.github.com/repos/google/certificate-transparency-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/certificate-transparency-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/certificate-transparency-go/teams","hooks_url":"https://api.github.com/repos/google/certificate-transparency-go/hooks","issue_events_url":"https://api.github.com/repos/google/certificate-transparency-go/issues/events{/number}","events_url":"https://api.github.com/repos/google/certificate-transparency-go/events","assignees_url":"https://api.github.com/repos/google/certificate-transparency-go/assignees{/user}","branches_url":"https://api.github.com/repos/google/certificate-transparency-go/branches{/branch}","tags_url":"https://api.github.com/repos/google/certificate-transparency-go/tags","blobs_url":"https://api.github.com/repos/google/certificate-transparency-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/certificate-transparency-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/certificate-transparency-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/certificate-transparency-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/certificate-transparency-go/statuses/{sha}","languages_url":"https://api.github.com/repos/google/certificate-transparency-go/languages","stargazers_url":"https://api.github.com/repos/google/certificate-transparency-go/stargazers","contributors_url":"https://api.github.com/repos/google/certificate-transparency-go/contributors","subscribers_url":"https://api.github.com/repos/google/certificate-transparency-go/subscribers","subscription_url":"https://api.github.com/repos/google/certificate-transparency-go/subscription","commits_url":"https://api.github.com/repos/google/certificate-transparency-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/certificate-transparency-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/certificate-transparency-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/certificate-transparency-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/certificate-transparency-go/contents/{+path}","compare_url":"https://api.github.com/repos/google/certificate-transparency-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/certificate-transparency-go/merges","archive_url":"https://api.github.com/repos/google/certificate-transparency-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/certificate-transparency-go/downloads","issues_url":"https://api.github.com/repos/google/certificate-transparency-go/issues{/number}","pulls_url":"https://api.github.com/repos/google/certificate-transparency-go/pulls{/number}","milestones_url":"https://api.github.com/repos/google/certificate-transparency-go/milestones{/number}","notifications_url":"https://api.github.com/repos/google/certificate-transparency-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/certificate-transparency-go/labels{/name}","releases_url":"https://api.github.com/repos/google/certificate-transparency-go/releases{/id}","deployments_url":"https://api.github.com/repos/google/certificate-transparency-go/deployments","created_at":"2017-05-08T14:22:46Z","updated_at":"2018-11-21T15:48:15Z","pushed_at":"2018-11-21T15:48:12Z","git_url":"git://github.com/google/certificate-transparency-go.git","ssh_url":"git@github.com:google/certificate-transparency-go.git","clone_url":"https://github.com/google/certificate-transparency-go.git","svn_url":"https://github.com/google/certificate-transparency-go","homepage":"http://www.certificate-transparency.org/","size":8093,"stargazers_count":116,"watchers_count":116,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":59,"mirror_url":null,"archived":false,"open_issues_count":13,"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":59,"open_issues":13,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405"},"html":{"href":"https://github.com/google/certificate-transparency-go/pull/405"},"issue":{"href":"https://api.github.com/repos/google/certificate-transparency-go/issues/405"},"comments":{"href":"https://api.github.com/repos/google/certificate-transparency-go/issues/405/comments"},"review_comments":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405/comments"},"review_comment":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/certificate-transparency-go/pulls/405/commits"},"statuses":{"href":"https://api.github.com/repos/google/certificate-transparency-go/statuses/18a563070e3248aa60ea493918ddefc557bddd83"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"daviddrysdale"}}