GitHub PullRequestReviewCommentEvent at 2014-12-09 00:21:53
Repository: go-ipfs
Actor: jbenet
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/21498660","id":21498660,"diff_hunk":"@@ -0,0 +1,121 @@\n+package core\n+\n+import (\n+\t\"math/rand\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\tcontext \"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context\"\n+\tma \"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr\"\n+\tconfig \"github.com/jbenet/go-ipfs/config\"\n+\tinet \"github.com/jbenet/go-ipfs/net\"\n+\tpeer \"github.com/jbenet/go-ipfs/peer\"\n+\tdht \"github.com/jbenet/go-ipfs/routing/dht\"\n+)\n+\n+const (\n+\tperiod                          = 30 * time.Second // how often to check connection status\n+\tconnectiontimeout time.Duration = period / 3       // duration to wait when attempting to connect\n+\trecoveryThreshold               = 4                // attempt to bootstrap if connection count falls below this value\n+)\n+\n+func superviseConnections(parent context.Context,\n+\tn inet.Network,\n+\troute *dht.IpfsDHT, // TODO depend on abstract interface for testing purposes\n+\tstore peer.Peerstore,\n+\tpeers []*config.BootstrapPeer) error {\n+\n+\tfor {\n+\t\tctx, _ := context.WithTimeout(parent, connectiontimeout)\n+\t\t// TODO get config from disk so |peers| always reflects the latest\n+\t\t// information\n+\t\tif err := bootstrap(ctx, n, route, store, peers); err != nil {\n+\t\t\tlog.Error(err)\n+\t\t}\n+\t\tselect {\n+\t\tcase <-parent.Done():\n+\t\t\treturn parent.Err()\n+\t\tcase <-time.Tick(period):\n+\t\t}\n+\t}\n+\treturn nil\n+}\n+\n+func bootstrap(ctx context.Context,\n+\tn inet.Network,\n+\tr *dht.IpfsDHT,\n+\tps peer.Peerstore,\n+\tboots []*config.BootstrapPeer) error {\n+\n+\tif len(n.GetConnections()) >= recoveryThreshold {\n+\t\treturn nil\n+\t}\n+\tnumCxnsToCreate := recoveryThreshold - len(n.GetConnections())\n+\n+\tvar bootstrapPeers []peer.Peer\n+\tfor _, bootstrap := range boots {\n+\t\tp, err := toPeer(ps, bootstrap)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tbootstrapPeers = append(bootstrapPeers, p)\n+\t}\n+\n+\tvar notConnected []peer.Peer\n+\tfor _, p := range bootstrapPeers {\n+\t\tif !n.IsConnected(p) {\n+\t\t\tnotConnected = append(notConnected, p)\n+\t\t}\n+\t}\n+\n+\tvar randomSubset []peer.Peer\n+\tfor _, val := range rand.Perm(numCxnsToCreate) {\n+\t\trandomSubset = append(randomSubset, notConnected[val])\n+\t}\n+\tif err := connect(ctx, r, randomSubset); err != nil {\n+\t\treturn err\n+\t}","path":"core/bootstrap.go","position":77,"original_position":77,"commit_id":"11caa54fc66fd8d83db6d48faa5ce8e23c918bbc","original_commit_id":"11caa54fc66fd8d83db6d48faa5ce8e23c918bbc","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"body":"i'd still like a go-underscore or something... though would have to cast all over the place without generics :(","created_at":"2014-12-09T00:21:53Z","updated_at":"2014-12-09T00:21:53Z","html_url":"https://github.com/jbenet/go-ipfs/pull/422#discussion_r21498660","pull_request_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422","_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/21498660"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/422#discussion_r21498660"},"pull_request":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422"}}},"pull_request":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422","id":25709359,"html_url":"https://github.com/jbenet/go-ipfs/pull/422","diff_url":"https://github.com/jbenet/go-ipfs/pull/422.diff","patch_url":"https://github.com/jbenet/go-ipfs/pull/422.patch","issue_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/422","number":422,"state":"open","locked":false,"title":"feat(core) supervise bootstrap connections","user":{"login":"maybebtc","id":734339,"avatar_url":"https://avatars.githubusercontent.com/u/734339?v=3","gravatar_id":"","url":"https://api.github.com/users/maybebtc","html_url":"https://github.com/maybebtc","followers_url":"https://api.github.com/users/maybebtc/followers","following_url":"https://api.github.com/users/maybebtc/following{/other_user}","gists_url":"https://api.github.com/users/maybebtc/gists{/gist_id}","starred_url":"https://api.github.com/users/maybebtc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maybebtc/subscriptions","organizations_url":"https://api.github.com/users/maybebtc/orgs","repos_url":"https://api.github.com/users/maybebtc/repos","events_url":"https://api.github.com/users/maybebtc/events{/privacy}","received_events_url":"https://api.github.com/users/maybebtc/received_events","type":"User","site_admin":false},"body":"fixes #416 ","created_at":"2014-12-09T00:13:46Z","updated_at":"2014-12-09T00:21:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc8ec5770870360ffcec8f009ff84250c14aec0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422/commits","review_comments_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422/comments","review_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/422/comments","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/11caa54fc66fd8d83db6d48faa5ce8e23c918bbc","head":{"label":"jbenet:feat/supervise-connections","ref":"feat/supervise-connections","sha":"11caa54fc66fd8d83db6d48faa5ce8e23c918bbc","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2014-12-08T23:03:40Z","pushed_at":"2014-12-09T00:16:34Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":9537,"stargazers_count":207,"watchers_count":207,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":108,"forks":31,"open_issues":108,"watchers":207,"default_branch":"master"}},"base":{"label":"jbenet:master","ref":"master","sha":"422d3429086126bb8dde09985bce1a84a8f36ead","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2014-12-08T23:03:40Z","pushed_at":"2014-12-09T00:16:34Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":9537,"stargazers_count":207,"watchers_count":207,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":108,"forks":31,"open_issues":108,"watchers":207,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/422"},"issue":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/422"},"comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/422/comments"},"review_comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422/comments"},"review_comment":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/422/commits"},"statuses":{"href":"https://api.github.com/repos/jbenet/go-ipfs/statuses/11caa54fc66fd8d83db6d48faa5ce8e23c918bbc"}}}}