{"action":"created","comment":{"url":"https://api.github.com/repos/hyperledger/fabric/pulls/comments/68503781","id":68503781,"diff_hunk":"@@ -322,6 +322,14 @@ func (p *PeerImpl) GetPeers() (*pb.PeersMessage, error) {\n \treturn peersMessage, nil\n }\n \n+func getPeerAddresses(peersMsg *pb.PeersMessage) []string {\n+\tvar addresses []string\n+\tfor _, v := range peersMsg.GetPeers() {\n+\t\taddresses = append(addresses, v.Address)","path":"core/peer/peer.go","position":100,"original_position":100,"commit_id":"3717b33de1f3742c37729ca8ef38968f13355cb7","original_commit_id":"3717b33de1f3742c37729ca8ef38968f13355cb7","user":{"login":"jyellick","id":7431583,"avatar_url":"https://avatars.githubusercontent.com/u/7431583?v=3","gravatar_id":"","url":"https://api.github.com/users/jyellick","html_url":"https://github.com/jyellick","followers_url":"https://api.github.com/users/jyellick/followers","following_url":"https://api.github.com/users/jyellick/following{/other_user}","gists_url":"https://api.github.com/users/jyellick/gists{/gist_id}","starred_url":"https://api.github.com/users/jyellick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyellick/subscriptions","organizations_url":"https://api.github.com/users/jyellick/orgs","repos_url":"https://api.github.com/users/jyellick/repos","events_url":"https://api.github.com/users/jyellick/events{/privacy}","received_events_url":"https://api.github.com/users/jyellick/received_events","type":"User","site_admin":false},"body":"Not certain how frequently this is called, but the `addresses` length looks like it could be computed to reduce allocations rather than appended up to size.","created_at":"2016-06-26T14:19:16Z","updated_at":"2016-06-26T14:19:16Z","html_url":"https://github.com/hyperledger/fabric/pull/2016#discussion_r68503781","pull_request_url":"https://api.github.com/repos/hyperledger/fabric/pulls/2016","_links":{"self":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/comments/68503781"},"html":{"href":"https://github.com/hyperledger/fabric/pull/2016#discussion_r68503781"},"pull_request":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2016"}}},"pull_request":{"url":"https://api.github.com/repos/hyperledger/fabric/pulls/2016","id":75218778,"html_url":"https://github.com/hyperledger/fabric/pull/2016","diff_url":"https://github.com/hyperledger/fabric/pull/2016.diff","patch_url":"https://github.com/hyperledger/fabric/pull/2016.patch","issue_url":"https://api.github.com/repos/hyperledger/fabric/issues/2016","number":2016,"state":"open","locked":false,"title":"Discovery: maintain and persist list of recent connections","user":{"login":"kchristidis","id":14876848,"avatar_url":"https://avatars.githubusercontent.com/u/14876848?v=3","gravatar_id":"","url":"https://api.github.com/users/kchristidis","html_url":"https://github.com/kchristidis","followers_url":"https://api.github.com/users/kchristidis/followers","following_url":"https://api.github.com/users/kchristidis/following{/other_user}","gists_url":"https://api.github.com/users/kchristidis/gists{/gist_id}","starred_url":"https://api.github.com/users/kchristidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kchristidis/subscriptions","organizations_url":"https://api.github.com/users/kchristidis/orgs","repos_url":"https://api.github.com/users/kchristidis/repos","events_url":"https://api.github.com/users/kchristidis/events{/privacy}","received_events_url":"https://api.github.com/users/kchristidis/received_events","type":"User","site_admin":false},"body":"## Description\r\nWith this set of changes, every node should now maintain a list of recent connections via the `discovery` service. When the appropriate flag (`peer.discovery.persist`) in the config file is set to `true` (default), the node also persists the discovery list to the DB, and repeats this task whenever the list is updated. If the node crashes, it will load the list upon restarting, and attempt to connect to the addresses it carries, via the touch service.\r\n\r\nThis PR extends the existing `discovery` service by including non-anchor nodes in its list, and by adding persistence support. It moves the `discovery` package in the `core` directory as this seemed a much more logical fit.\r\n\r\nThis set of changes also simplifies the peer connection logic in the `peer` package, and adds support for the `discovery.maxTouchNodes` configuration option originally added by @jeffgarratt; now the touch service will attempt to connect to a maximum of `maxTouchNodes` nodes. (This new list is generated randomly from the discovery list.)\r\n\r\n## Motivation and Context\r\nConsider this scenario:\r\n\r\n1. All the nodes in a network use the same anchor node.\r\n2. The anchor node crashes.\r\n3. A node crashes and comes back online while the anchor node is still down.\r\n\r\nThis node will not be able to connect to its peers, i.e. we will have a network partition. Do note that the practice listed in step 1 is how we actually launch all of our test networks today. This problem was discovered in #1874.\r\n\r\nWith this PR, such issues are fixed.\r\n\r\n## How Has This Been Tested?\r\n- New unit tests for the new functions added in the `discovery` and `util` package.\r\n-  2 new behave tests have been added, provided by @lhaskins and @scottz64.\r\n- Passes all tests locally.\r\n\r\n## Checklist:\r\n- [x] I have added a [Signed-off-by](https://github.com/hyperledger/fabric/blob/master/CONTRIBUTING.md#legal-stuff).\r\n- [x] I have either added documentation to cover my changes or this change requires no new documentation.\r\n- [x] I have either added unit tests to cover my changes or this change requires no new tests.\r\n- [x] I have run [golint](https://github.com/golang/lint) and have fixed valid warnings in code I have added or modified. This tool generates false positives so you may choose to ignore some warnings. The goal is clean, consistent, and readable code.\r\n\r\nSigned-off-by: Kostas Christidis <kchristidis@us.ibm.com.>","created_at":"2016-06-26T01:24:46Z","updated_at":"2016-06-26T14:19:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bddf96e8b99162e800a80c93ebfc190e4ea74949","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperledger/fabric/pulls/2016/commits","review_comments_url":"https://api.github.com/repos/hyperledger/fabric/pulls/2016/comments","review_comment_url":"https://api.github.com/repos/hyperledger/fabric/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperledger/fabric/issues/2016/comments","statuses_url":"https://api.github.com/repos/hyperledger/fabric/statuses/3717b33de1f3742c37729ca8ef38968f13355cb7","head":{"label":"kchristidis:fix-network-partitions","ref":"fix-network-partitions","sha":"3717b33de1f3742c37729ca8ef38968f13355cb7","user":{"login":"kchristidis","id":14876848,"avatar_url":"https://avatars.githubusercontent.com/u/14876848?v=3","gravatar_id":"","url":"https://api.github.com/users/kchristidis","html_url":"https://github.com/kchristidis","followers_url":"https://api.github.com/users/kchristidis/followers","following_url":"https://api.github.com/users/kchristidis/following{/other_user}","gists_url":"https://api.github.com/users/kchristidis/gists{/gist_id}","starred_url":"https://api.github.com/users/kchristidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kchristidis/subscriptions","organizations_url":"https://api.github.com/users/kchristidis/orgs","repos_url":"https://api.github.com/users/kchristidis/repos","events_url":"https://api.github.com/users/kchristidis/events{/privacy}","received_events_url":"https://api.github.com/users/kchristidis/received_events","type":"User","site_admin":false},"repo":{"id":51781476,"name":"fabric","full_name":"kchristidis/fabric","owner":{"login":"kchristidis","id":14876848,"avatar_url":"https://avatars.githubusercontent.com/u/14876848?v=3","gravatar_id":"","url":"https://api.github.com/users/kchristidis","html_url":"https://github.com/kchristidis","followers_url":"https://api.github.com/users/kchristidis/followers","following_url":"https://api.github.com/users/kchristidis/following{/other_user}","gists_url":"https://api.github.com/users/kchristidis/gists{/gist_id}","starred_url":"https://api.github.com/users/kchristidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kchristidis/subscriptions","organizations_url":"https://api.github.com/users/kchristidis/orgs","repos_url":"https://api.github.com/users/kchristidis/repos","events_url":"https://api.github.com/users/kchristidis/events{/privacy}","received_events_url":"https://api.github.com/users/kchristidis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kchristidis/fabric","description":"Blockchain fabric code","fork":true,"url":"https://api.github.com/repos/kchristidis/fabric","forks_url":"https://api.github.com/repos/kchristidis/fabric/forks","keys_url":"https://api.github.com/repos/kchristidis/fabric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kchristidis/fabric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kchristidis/fabric/teams","hooks_url":"https://api.github.com/repos/kchristidis/fabric/hooks","issue_events_url":"https://api.github.com/repos/kchristidis/fabric/issues/events{/number}","events_url":"https://api.github.com/repos/kchristidis/fabric/events","assignees_url":"https://api.github.com/repos/kchristidis/fabric/assignees{/user}","branches_url":"https://api.github.com/repos/kchristidis/fabric/branches{/branch}","tags_url":"https://api.github.com/repos/kchristidis/fabric/tags","blobs_url":"https://api.github.com/repos/kchristidis/fabric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kchristidis/fabric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kchristidis/fabric/git/refs{/sha}","trees_url":"https://api.github.com/repos/kchristidis/fabric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kchristidis/fabric/statuses/{sha}","languages_url":"https://api.github.com/repos/kchristidis/fabric/languages","stargazers_url":"https://api.github.com/repos/kchristidis/fabric/stargazers","contributors_url":"https://api.github.com/repos/kchristidis/fabric/contributors","subscribers_url":"https://api.github.com/repos/kchristidis/fabric/subscribers","subscription_url":"https://api.github.com/repos/kchristidis/fabric/subscription","commits_url":"https://api.github.com/repos/kchristidis/fabric/commits{/sha}","git_commits_url":"https://api.github.com/repos/kchristidis/fabric/git/commits{/sha}","comments_url":"https://api.github.com/repos/kchristidis/fabric/comments{/number}","issue_comment_url":"https://api.github.com/repos/kchristidis/fabric/issues/comments{/number}","contents_url":"https://api.github.com/repos/kchristidis/fabric/contents/{+path}","compare_url":"https://api.github.com/repos/kchristidis/fabric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kchristidis/fabric/merges","archive_url":"https://api.github.com/repos/kchristidis/fabric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kchristidis/fabric/downloads","issues_url":"https://api.github.com/repos/kchristidis/fabric/issues{/number}","pulls_url":"https://api.github.com/repos/kchristidis/fabric/pulls{/number}","milestones_url":"https://api.github.com/repos/kchristidis/fabric/milestones{/number}","notifications_url":"https://api.github.com/repos/kchristidis/fabric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kchristidis/fabric/labels{/name}","releases_url":"https://api.github.com/repos/kchristidis/fabric/releases{/id}","deployments_url":"https://api.github.com/repos/kchristidis/fabric/deployments","created_at":"2016-02-15T19:57:54Z","updated_at":"2016-04-19T05:35:47Z","pushed_at":"2016-06-26T00:52:13Z","git_url":"git://github.com/kchristidis/fabric.git","ssh_url":"git@github.com:kchristidis/fabric.git","clone_url":"https://github.com/kchristidis/fabric.git","svn_url":"https://github.com/kchristidis/fabric","homepage":"","size":44583,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hyperledger:v0.5-developer-preview","ref":"v0.5-developer-preview","sha":"9f5666f7d39741ffa6e7bb38828f441fc42c4d57","user":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":42975662,"name":"fabric","full_name":"hyperledger/fabric","owner":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperledger/fabric","description":"Fabric is a blockchain project in Incubation proposed to the community and documented at https://goo.gl/RYQZ5N.  Information on what Incubation entails can be found in the Hyperledger Project Lifecycle document (https://goo.gl/4edNRc)","fork":false,"url":"https://api.github.com/repos/hyperledger/fabric","forks_url":"https://api.github.com/repos/hyperledger/fabric/forks","keys_url":"https://api.github.com/repos/hyperledger/fabric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/fabric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/fabric/teams","hooks_url":"https://api.github.com/repos/hyperledger/fabric/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/fabric/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/fabric/events","assignees_url":"https://api.github.com/repos/hyperledger/fabric/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/fabric/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/fabric/tags","blobs_url":"https://api.github.com/repos/hyperledger/fabric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/fabric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/fabric/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/fabric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/fabric/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/fabric/languages","stargazers_url":"https://api.github.com/repos/hyperledger/fabric/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/fabric/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/fabric/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/fabric/subscription","commits_url":"https://api.github.com/repos/hyperledger/fabric/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/fabric/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/fabric/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/fabric/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/fabric/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/fabric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/fabric/merges","archive_url":"https://api.github.com/repos/hyperledger/fabric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/fabric/downloads","issues_url":"https://api.github.com/repos/hyperledger/fabric/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/fabric/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/fabric/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/fabric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/fabric/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/fabric/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/fabric/deployments","created_at":"2015-09-23T03:17:14Z","updated_at":"2016-06-26T12:41:29Z","pushed_at":"2016-06-26T09:04:21Z","git_url":"git://github.com/hyperledger/fabric.git","ssh_url":"git@github.com:hyperledger/fabric.git","clone_url":"https://github.com/hyperledger/fabric.git","svn_url":"https://github.com/hyperledger/fabric","homepage":"","size":78835,"stargazers_count":836,"watchers_count":836,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":751,"mirror_url":null,"open_issues_count":360,"forks":751,"open_issues":360,"watchers":836,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2016"},"html":{"href":"https://github.com/hyperledger/fabric/pull/2016"},"issue":{"href":"https://api.github.com/repos/hyperledger/fabric/issues/2016"},"comments":{"href":"https://api.github.com/repos/hyperledger/fabric/issues/2016/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2016/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperledger/fabric/pulls/2016/commits"},"statuses":{"href":"https://api.github.com/repos/hyperledger/fabric/statuses/3717b33de1f3742c37729ca8ef38968f13355cb7"}}}}
{"actor":{"display_login":"jyellick"}}