{"action":"created","comment":{"url":"https://api.github.com/repos/status-im/status-go/pulls/comments/181019134","pull_request_review_id":111543956,"id":181019134,"diff_hunk":"@@ -92,42 +97,101 @@ func (p *PeerPool) Start(server *p2p.Server) error {\n \treturn nil\n }\n \n+// restartDiscovery and search for topics that have peer count below min\n+func (p *PeerPool) restartDiscovery(server *p2p.Server) error {\n+\tif server.DiscV5 == nil {\n+\t\tntab, err := StartDiscv5(server)\n+\t\tif err != nil {\n+\t\t\tlog.Error(\"starting discv5 failed\", \"error\", err, \"retry in\", discoveryRestartTimeout)\n+\t\t\treturn err\n+\t\t}\n+\t\tlog.Debug(\"restarted discovery from peer pool\")\n+\t\tserver.DiscV5 = ntab\n+\t}\n+\tfor _, t := range p.topics {\n+\t\tif !t.BelowMin() || t.SearchRunning() {\n+\t\t\tcontinue\n+\t\t}\n+\t\terr := t.StartSearch(server)\n+\t\tif err != nil {\n+\t\t\tlog.Error(\"search failed to start\", \"error\", err)\n+\t\t}\n+\t}\n+\treturn nil\n+}\n+\n // handleServerPeers watches server peer events, notifies topic pools about changes\n // in the peer set and stops the discv5 if all topic pools collected enough peers.\n func (p *PeerPool) handleServerPeers(server *p2p.Server, events <-chan *p2p.PeerEvent) {\n+\tvar (\n+\t\tretryDiscv5 <-chan time.Time\n+\t)\n+\n \tfor {\n \t\tselect {\n \t\tcase <-p.quit:\n \t\t\treturn\n+\t\tcase <-retryDiscv5:","path":"geth/peers/peerpool.go","position":64,"original_position":64,"commit_id":"3afc33a68004ba2535e2898ef00273c10cebd2f7","original_commit_id":"3afc33a68004ba2535e2898ef00273c10cebd2f7","user":{"login":"dshulyak","id":1964576,"avatar_url":"https://avatars2.githubusercontent.com/u/1964576?v=4","gravatar_id":"","url":"https://api.github.com/users/dshulyak","html_url":"https://github.com/dshulyak","followers_url":"https://api.github.com/users/dshulyak/followers","following_url":"https://api.github.com/users/dshulyak/following{/other_user}","gists_url":"https://api.github.com/users/dshulyak/gists{/gist_id}","starred_url":"https://api.github.com/users/dshulyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshulyak/subscriptions","organizations_url":"https://api.github.com/users/dshulyak/orgs","repos_url":"https://api.github.com/users/dshulyak/repos","events_url":"https://api.github.com/users/dshulyak/events{/privacy}","received_events_url":"https://api.github.com/users/dshulyak/received_events","type":"User","site_admin":false},"body":"but all of this happens in the same goroutine, what kind of race are you thinking about?\r\n\r\nfor example:\r\n1. drop the peer for topic x and limit is below min\r\n2. start discv5 and start search for topic x\r\n3. drop the peer for topic y with limit below min\r\n4. discv5 already started, so just start search for topic y","created_at":"2018-04-12T09:28:46Z","updated_at":"2018-04-12T09:28:46Z","html_url":"https://github.com/status-im/status-go/pull/801#discussion_r181019134","pull_request_url":"https://api.github.com/repos/status-im/status-go/pulls/801","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/status-im/status-go/pulls/comments/181019134"},"html":{"href":"https://github.com/status-im/status-go/pull/801#discussion_r181019134"},"pull_request":{"href":"https://api.github.com/repos/status-im/status-go/pulls/801"}},"in_reply_to_id":181002385},"pull_request":{"url":"https://api.github.com/repos/status-im/status-go/pulls/801","id":179602011,"html_url":"https://github.com/status-im/status-go/pull/801","diff_url":"https://github.com/status-im/status-go/pull/801.diff","patch_url":"https://github.com/status-im/status-go/pull/801.patch","issue_url":"https://api.github.com/repos/status-im/status-go/issues/801","number":801,"state":"open","locked":false,"title":"Peerpool failover","user":{"login":"dshulyak","id":1964576,"avatar_url":"https://avatars2.githubusercontent.com/u/1964576?v=4","gravatar_id":"","url":"https://api.github.com/users/dshulyak","html_url":"https://github.com/dshulyak","followers_url":"https://api.github.com/users/dshulyak/followers","following_url":"https://api.github.com/users/dshulyak/following{/other_user}","gists_url":"https://api.github.com/users/dshulyak/gists{/gist_id}","starred_url":"https://api.github.com/users/dshulyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshulyak/subscriptions","organizations_url":"https://api.github.com/users/dshulyak/orgs","repos_url":"https://api.github.com/users/dshulyak/repos","events_url":"https://api.github.com/users/dshulyak/events{/privacy}","received_events_url":"https://api.github.com/users/dshulyak/received_events","type":"User","site_admin":false},"body":"Please see extended simulation in peerpool_test for failover scenario, I will describe it in words later.\r\n\r\nOnly the last commit in this PR is relevant, I created a separate one because peer pool is already complex enough.","created_at":"2018-04-05T08:15:53Z","updated_at":"2018-04-12T09:28:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfb8861faa5620568731a997d3de0521f8b99ab0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/status-go/pulls/801/commits","review_comments_url":"https://api.github.com/repos/status-im/status-go/pulls/801/comments","review_comment_url":"https://api.github.com/repos/status-im/status-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/status-go/issues/801/comments","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/3afc33a68004ba2535e2898ef00273c10cebd2f7","head":{"label":"status-im:peerpool_f","ref":"peerpool_f","sha":"3afc33a68004ba2535e2898ef00273c10cebd2f7","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":61047867,"name":"status-go","full_name":"status-im/status-go","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-go","description":"The Status module that consumes go-ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-go","forks_url":"https://api.github.com/repos/status-im/status-go/forks","keys_url":"https://api.github.com/repos/status-im/status-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-go/teams","hooks_url":"https://api.github.com/repos/status-im/status-go/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-go/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-go/events","assignees_url":"https://api.github.com/repos/status-im/status-go/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-go/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-go/tags","blobs_url":"https://api.github.com/repos/status-im/status-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-go/languages","stargazers_url":"https://api.github.com/repos/status-im/status-go/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-go/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-go/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-go/subscription","commits_url":"https://api.github.com/repos/status-im/status-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-go/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-go/merges","archive_url":"https://api.github.com/repos/status-im/status-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-go/downloads","issues_url":"https://api.github.com/repos/status-im/status-go/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-go/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-go/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-go/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-go/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-go/deployments","created_at":"2016-06-13T15:32:03Z","updated_at":"2018-04-11T15:41:54Z","pushed_at":"2018-04-12T09:05:30Z","git_url":"git://github.com/status-im/status-go.git","ssh_url":"git@github.com:status-im/status-go.git","clone_url":"https://github.com/status-im/status-go.git","svn_url":"https://github.com/status-im/status-go","homepage":"https://status.im","size":37655,"stargazers_count":364,"watchers_count":364,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":119,"mirror_url":null,"archived":false,"open_issues_count":60,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":119,"open_issues":60,"watchers":364,"default_branch":"develop"}},"base":{"label":"status-im:develop","ref":"develop","sha":"ba9a25e284c4d2decdf7c1b53f807b36da78dbd0","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":61047867,"name":"status-go","full_name":"status-im/status-go","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-go","description":"The Status module that consumes go-ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-go","forks_url":"https://api.github.com/repos/status-im/status-go/forks","keys_url":"https://api.github.com/repos/status-im/status-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-go/teams","hooks_url":"https://api.github.com/repos/status-im/status-go/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-go/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-go/events","assignees_url":"https://api.github.com/repos/status-im/status-go/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-go/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-go/tags","blobs_url":"https://api.github.com/repos/status-im/status-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-go/languages","stargazers_url":"https://api.github.com/repos/status-im/status-go/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-go/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-go/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-go/subscription","commits_url":"https://api.github.com/repos/status-im/status-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-go/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-go/merges","archive_url":"https://api.github.com/repos/status-im/status-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-go/downloads","issues_url":"https://api.github.com/repos/status-im/status-go/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-go/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-go/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-go/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-go/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-go/deployments","created_at":"2016-06-13T15:32:03Z","updated_at":"2018-04-11T15:41:54Z","pushed_at":"2018-04-12T09:05:30Z","git_url":"git://github.com/status-im/status-go.git","ssh_url":"git@github.com:status-im/status-go.git","clone_url":"https://github.com/status-im/status-go.git","svn_url":"https://github.com/status-im/status-go","homepage":"https://status.im","size":37655,"stargazers_count":364,"watchers_count":364,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":119,"mirror_url":null,"archived":false,"open_issues_count":60,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":119,"open_issues":60,"watchers":364,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/status-go/pulls/801"},"html":{"href":"https://github.com/status-im/status-go/pull/801"},"issue":{"href":"https://api.github.com/repos/status-im/status-go/issues/801"},"comments":{"href":"https://api.github.com/repos/status-im/status-go/issues/801/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/status-go/pulls/801/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/status-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/status-go/pulls/801/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/status-go/statuses/3afc33a68004ba2535e2898ef00273c10cebd2f7"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dshulyak"}}