{"action":"created","comment":{"url":"https://api.github.com/repos/keybase/client/pulls/comments/92842268","pull_request_review_id":13365766,"id":92842268,"diff_hunk":"@@ -0,0 +1,126 @@\n+package service\n+\n+import (\n+\t\"errors\"\n+\t\"github.com/keybase/client/go/engine\"\n+\t\"github.com/keybase/client/go/libkb\"\n+\t\"github.com/keybase/client/go/protocol/keybase1\"\n+\t\"sync\"\n+)\n+\n+type uidSet map[keybase1.UID]bool\n+\n+func newUIDSet(v []keybase1.UID) uidSet {\n+\tret := make(uidSet)\n+\tfor _, e := range v {\n+\t\tret[e] = true\n+\t}\n+\treturn ret\n+}\n+\n+func (a uidSet) subtract(b uidSet) uidSet {\n+\tret := make(uidSet)\n+\tfor e := range a {\n+\t\tif !b[e] {\n+\t\t\tret[e] = true\n+\t\t}\n+\t}\n+\treturn ret\n+}\n+\n+type BackgroundIdentifier struct {\n+\tlibkb.Contextified\n+\tsync.Mutex\n+\tuid             keybase1.UID\n+\tengine          *engine.BackgroundIdentifier\n+\tstopCh          chan<- struct{}\n+\tisDead          bool\n+\tlastFollowerSet uidSet\n+}\n+\n+func RunBackgroundIdentifier(g *libkb.GlobalContext, u keybase1.UID) (*BackgroundIdentifier, error) {\n+\tch := make(chan struct{})\n+\teng := engine.NewBackgroundIdentifier(g, ch)\n+\tret := &BackgroundIdentifier{\n+\t\tContextified:    libkb.NewContextified(g),\n+\t\tuid:             u,\n+\t\tengine:          eng,\n+\t\tstopCh:          ch,\n+\t\tlastFollowerSet: newUIDSet(nil),\n+\t}\n+\n+\terr := ret.populateWithFollowees()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tgo func() {\n+\t\terr := engine.RunEngine(eng, &engine.Context{})\n+\t\tif err != nil {\n+\t\t\tg.Log.Warning(\"Background identifier failed: %s\\n\", err)\n+\t\t}\n+\t}()\n+\treturn ret, nil\n+}\n+\n+func (b *BackgroundIdentifier) populateWithFollowees() error {\n+\tb.Lock()\n+\tdefer b.Unlock()\n+\tuids, err := b.G().CachedUserLoader.ListFollowedUIDs(b.uid)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tnewSet := newUIDSet(uids)\n+\tadditions := newSet.subtract(b.lastFollowerSet)\n+\tfor u := range additions {\n+\t\tb.engine.Add(u)\n+\t}\n+\tremovals := b.lastFollowerSet.subtract(newSet)\n+\tfor u := range removals {\n+\t\tb.engine.Remove(u)\n+\t}\n+\tb.lastFollowerSet = newSet\n+\treturn nil\n+}\n+\n+func (b *BackgroundIdentifier) Shutdown() {\n+\tdefer b.G().Trace(\"BackgroundIdentifier#Shutdown\", func() error { return nil })()\n+\tb.Lock()\n+\tdefer b.Unlock()\n+\tif b.isDead {\n+\t\tb.G().Log.Debug(\"identifier was already shutdown\")\n+\t\treturn\n+\t}\n+\tb.isDead = true\n+\tb.stopCh <- struct{}{}\n+}\n+\n+func (b *BackgroundIdentifier) Logout() { b.Shutdown() }\n+\n+func (b *BackgroundIdentifier) Login(u keybase1.UID) (bgi *BackgroundIdentifier, err error) {\n+\tdefer b.G().Trace(\"BackgroundIdentifier#Login\", func() error { return err })()\n+\tif b.uid.Equal(u) {","path":"go/service/bg_identifier.go","position":102,"original_position":102,"commit_id":"2ee49beefa399dfa004aee5a73caf11206d649ca","original_commit_id":"2ee49beefa399dfa004aee5a73caf11206d649ca","user":{"login":"maxtaco","id":866815,"avatar_url":"https://avatars.githubusercontent.com/u/866815?v=3","gravatar_id":"","url":"https://api.github.com/users/maxtaco","html_url":"https://github.com/maxtaco","followers_url":"https://api.github.com/users/maxtaco/followers","following_url":"https://api.github.com/users/maxtaco/following{/other_user}","gists_url":"https://api.github.com/users/maxtaco/gists{/gist_id}","starred_url":"https://api.github.com/users/maxtaco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxtaco/subscriptions","organizations_url":"https://api.github.com/users/maxtaco/orgs","repos_url":"https://api.github.com/users/maxtaco/repos","events_url":"https://api.github.com/users/maxtaco/events{/privacy}","received_events_url":"https://api.github.com/users/maxtaco/received_events","type":"User","site_admin":false},"body":"you'll get a totally new BgIdentifier in that case. They're single use -- once they stop, the are never restarted.","created_at":"2016-12-16T16:33:25Z","updated_at":"2016-12-16T16:33:25Z","html_url":"https://github.com/keybase/client/pull/5125#discussion_r92842268","pull_request_url":"https://api.github.com/repos/keybase/client/pulls/5125","_links":{"self":{"href":"https://api.github.com/repos/keybase/client/pulls/comments/92842268"},"html":{"href":"https://github.com/keybase/client/pull/5125#discussion_r92842268"},"pull_request":{"href":"https://api.github.com/repos/keybase/client/pulls/5125"}}},"pull_request":{"url":"https://api.github.com/repos/keybase/client/pulls/5125","id":98243608,"html_url":"https://github.com/keybase/client/pull/5125","diff_url":"https://github.com/keybase/client/pull/5125.diff","patch_url":"https://github.com/keybase/client/pull/5125.patch","issue_url":"https://api.github.com/repos/keybase/client/issues/5125","number":5125,"state":"open","locked":false,"title":"working BG identifier integration","user":{"login":"maxtaco","id":866815,"avatar_url":"https://avatars.githubusercontent.com/u/866815?v=3","gravatar_id":"","url":"https://api.github.com/users/maxtaco","html_url":"https://github.com/maxtaco","followers_url":"https://api.github.com/users/maxtaco/followers","following_url":"https://api.github.com/users/maxtaco/following{/other_user}","gists_url":"https://api.github.com/users/maxtaco/gists{/gist_id}","starred_url":"https://api.github.com/users/maxtaco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxtaco/subscriptions","organizations_url":"https://api.github.com/users/maxtaco/orgs","repos_url":"https://api.github.com/users/maxtaco/repos","events_url":"https://api.github.com/users/maxtaco/events{/privacy}","received_events_url":"https://api.github.com/users/maxtaco/received_events","type":"User","site_admin":false},"body":"- tested by hand","created_at":"2016-12-15T22:27:25Z","updated_at":"2016-12-16T16:33:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac9a2c0bb46d5c211b8c857ec6faf00e17ebe1ca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/keybase/client/pulls/5125/commits","review_comments_url":"https://api.github.com/repos/keybase/client/pulls/5125/comments","review_comment_url":"https://api.github.com/repos/keybase/client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keybase/client/issues/5125/comments","statuses_url":"https://api.github.com/repos/keybase/client/statuses/2ee49beefa399dfa004aee5a73caf11206d649ca","head":{"label":"keybase:maxtaco/CORE-4230","ref":"maxtaco/CORE-4230","sha":"2ee49beefa399dfa004aee5a73caf11206d649ca","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":29099181,"name":"client","full_name":"keybase/client","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/client","description":"Keybase Go Library, Client, Service, OS X, iOS, Android, Electron","fork":false,"url":"https://api.github.com/repos/keybase/client","forks_url":"https://api.github.com/repos/keybase/client/forks","keys_url":"https://api.github.com/repos/keybase/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/client/teams","hooks_url":"https://api.github.com/repos/keybase/client/hooks","issue_events_url":"https://api.github.com/repos/keybase/client/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/client/events","assignees_url":"https://api.github.com/repos/keybase/client/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/client/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/client/tags","blobs_url":"https://api.github.com/repos/keybase/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/client/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/client/languages","stargazers_url":"https://api.github.com/repos/keybase/client/stargazers","contributors_url":"https://api.github.com/repos/keybase/client/contributors","subscribers_url":"https://api.github.com/repos/keybase/client/subscribers","subscription_url":"https://api.github.com/repos/keybase/client/subscription","commits_url":"https://api.github.com/repos/keybase/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/client/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/client/merges","archive_url":"https://api.github.com/repos/keybase/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/client/downloads","issues_url":"https://api.github.com/repos/keybase/client/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/client/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/client/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/client/labels{/name}","releases_url":"https://api.github.com/repos/keybase/client/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/client/deployments","created_at":"2015-01-11T17:17:12Z","updated_at":"2016-12-16T16:30:07Z","pushed_at":"2016-12-16T16:21:54Z","git_url":"git://github.com/keybase/client.git","ssh_url":"git@github.com:keybase/client.git","clone_url":"https://github.com/keybase/client.git","svn_url":"https://github.com/keybase/client","homepage":"","size":158511,"stargazers_count":895,"watchers_count":895,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":621,"forks":81,"open_issues":621,"watchers":895,"default_branch":"master"}},"base":{"label":"keybase:master","ref":"master","sha":"b77b86cd16876d6a7d2f628c5b7099e147e2b084","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":29099181,"name":"client","full_name":"keybase/client","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/client","description":"Keybase Go Library, Client, Service, OS X, iOS, Android, Electron","fork":false,"url":"https://api.github.com/repos/keybase/client","forks_url":"https://api.github.com/repos/keybase/client/forks","keys_url":"https://api.github.com/repos/keybase/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/client/teams","hooks_url":"https://api.github.com/repos/keybase/client/hooks","issue_events_url":"https://api.github.com/repos/keybase/client/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/client/events","assignees_url":"https://api.github.com/repos/keybase/client/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/client/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/client/tags","blobs_url":"https://api.github.com/repos/keybase/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/client/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/client/languages","stargazers_url":"https://api.github.com/repos/keybase/client/stargazers","contributors_url":"https://api.github.com/repos/keybase/client/contributors","subscribers_url":"https://api.github.com/repos/keybase/client/subscribers","subscription_url":"https://api.github.com/repos/keybase/client/subscription","commits_url":"https://api.github.com/repos/keybase/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/client/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/client/merges","archive_url":"https://api.github.com/repos/keybase/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/client/downloads","issues_url":"https://api.github.com/repos/keybase/client/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/client/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/client/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/client/labels{/name}","releases_url":"https://api.github.com/repos/keybase/client/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/client/deployments","created_at":"2015-01-11T17:17:12Z","updated_at":"2016-12-16T16:30:07Z","pushed_at":"2016-12-16T16:21:54Z","git_url":"git://github.com/keybase/client.git","ssh_url":"git@github.com:keybase/client.git","clone_url":"https://github.com/keybase/client.git","svn_url":"https://github.com/keybase/client","homepage":"","size":158511,"stargazers_count":895,"watchers_count":895,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":621,"forks":81,"open_issues":621,"watchers":895,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keybase/client/pulls/5125"},"html":{"href":"https://github.com/keybase/client/pull/5125"},"issue":{"href":"https://api.github.com/repos/keybase/client/issues/5125"},"comments":{"href":"https://api.github.com/repos/keybase/client/issues/5125/comments"},"review_comments":{"href":"https://api.github.com/repos/keybase/client/pulls/5125/comments"},"review_comment":{"href":"https://api.github.com/repos/keybase/client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keybase/client/pulls/5125/commits"},"statuses":{"href":"https://api.github.com/repos/keybase/client/statuses/2ee49beefa399dfa004aee5a73caf11206d649ca"}}}}
{"actor":{"display_login":"maxtaco"}}