{"action":"created","comment":{"url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/comments/33890637","id":33890637,"diff_hunk":"@@ -175,17 +175,23 @@ Server.prototype.close = function (cb) {\n   else cb(null)\n }\n \n-Server.prototype.getSwarm = function (infoHash, params) {\n+Server.prototype.getSwarm = function (infoHash, params, getSwarmCallback) {\n   var self = this\n   if (!params) params = {}\n   if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex')\n \n-  if (self._filter && !self._filter(infoHash, params)) return null\n-\n-  var swarm = self.torrents[infoHash]\n-  if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, self)\n-\n-  return swarm\n+  if (self._filter) {\n+    self._filter(infoHash, params, function (err, res) {\n+      if (err) return getSwarmCallback(err, null)\n+      var swarm = self.torrents[infoHash]\n+      if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, self)\n+      return getSwarmCallback(null, swarm)\n+    })\n+  } else {\n+    var swarm = self.torrents[infoHash]\n+    if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, self)\n+    return getSwarmCallback(null, swarm)","path":"server.js","position":26,"original_position":26,"commit_id":"18c170ef8786e3c37ac07069c85bdacd8222ff15","original_commit_id":"18c170ef8786e3c37ac07069c85bdacd8222ff15","user":{"login":"feross","id":121766,"avatar_url":"https://avatars.githubusercontent.com/u/121766?v=3","gravatar_id":"","url":"https://api.github.com/users/feross","html_url":"https://github.com/feross","followers_url":"https://api.github.com/users/feross/followers","following_url":"https://api.github.com/users/feross/following{/other_user}","gists_url":"https://api.github.com/users/feross/gists{/gist_id}","starred_url":"https://api.github.com/users/feross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feross/subscriptions","organizations_url":"https://api.github.com/users/feross/orgs","repos_url":"https://api.github.com/users/feross/repos","events_url":"https://api.github.com/users/feross/events{/privacy}","received_events_url":"https://api.github.com/users/feross/received_events","type":"User","site_admin":false},"body":"Better to pull these 3 lines into an inline function declaration than to repeat them","created_at":"2015-07-04T23:25:50Z","updated_at":"2015-07-04T23:25:50Z","html_url":"https://github.com/feross/bittorrent-tracker/pull/82#discussion_r33890637","pull_request_url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82","_links":{"self":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/comments/33890637"},"html":{"href":"https://github.com/feross/bittorrent-tracker/pull/82#discussion_r33890637"},"pull_request":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82"}}},"pull_request":{"url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82","id":39200324,"html_url":"https://github.com/feross/bittorrent-tracker/pull/82","diff_url":"https://github.com/feross/bittorrent-tracker/pull/82.diff","patch_url":"https://github.com/feross/bittorrent-tracker/pull/82.patch","issue_url":"https://api.github.com/repos/feross/bittorrent-tracker/issues/82","number":82,"state":"open","locked":false,"title":"Async getSwarm()","user":{"login":"lorentzkim","id":556509,"avatar_url":"https://avatars.githubusercontent.com/u/556509?v=3","gravatar_id":"","url":"https://api.github.com/users/lorentzkim","html_url":"https://github.com/lorentzkim","followers_url":"https://api.github.com/users/lorentzkim/followers","following_url":"https://api.github.com/users/lorentzkim/following{/other_user}","gists_url":"https://api.github.com/users/lorentzkim/gists{/gist_id}","starred_url":"https://api.github.com/users/lorentzkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorentzkim/subscriptions","organizations_url":"https://api.github.com/users/lorentzkim/orgs","repos_url":"https://api.github.com/users/lorentzkim/repos","events_url":"https://api.github.com/users/lorentzkim/events{/privacy}","received_events_url":"https://api.github.com/users/lorentzkim/received_events","type":"User","site_admin":false},"body":"https://github.com/feross/bittorrent-tracker/issues/80\r\n\r\nBasically, filter function takes in a callback making it asynchronous, and so does getSwarm(). Other parts of the code has been changed to reflect the new getSwarm(), as well as updated the tests.","created_at":"2015-07-04T00:40:03Z","updated_at":"2015-07-04T23:25:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fcc1363d79d31fe9154bbd4e0ab29b242dd1cf8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82/commits","review_comments_url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82/comments","review_comment_url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/feross/bittorrent-tracker/issues/82/comments","statuses_url":"https://api.github.com/repos/feross/bittorrent-tracker/statuses/18c170ef8786e3c37ac07069c85bdacd8222ff15","head":{"label":"lorentzkim:async_getswarm","ref":"async_getswarm","sha":"18c170ef8786e3c37ac07069c85bdacd8222ff15","user":{"login":"lorentzkim","id":556509,"avatar_url":"https://avatars.githubusercontent.com/u/556509?v=3","gravatar_id":"","url":"https://api.github.com/users/lorentzkim","html_url":"https://github.com/lorentzkim","followers_url":"https://api.github.com/users/lorentzkim/followers","following_url":"https://api.github.com/users/lorentzkim/following{/other_user}","gists_url":"https://api.github.com/users/lorentzkim/gists{/gist_id}","starred_url":"https://api.github.com/users/lorentzkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorentzkim/subscriptions","organizations_url":"https://api.github.com/users/lorentzkim/orgs","repos_url":"https://api.github.com/users/lorentzkim/repos","events_url":"https://api.github.com/users/lorentzkim/events{/privacy}","received_events_url":"https://api.github.com/users/lorentzkim/received_events","type":"User","site_admin":false},"repo":{"id":37873884,"name":"bittorrent-tracker","full_name":"lorentzkim/bittorrent-tracker","owner":{"login":"lorentzkim","id":556509,"avatar_url":"https://avatars.githubusercontent.com/u/556509?v=3","gravatar_id":"","url":"https://api.github.com/users/lorentzkim","html_url":"https://github.com/lorentzkim","followers_url":"https://api.github.com/users/lorentzkim/followers","following_url":"https://api.github.com/users/lorentzkim/following{/other_user}","gists_url":"https://api.github.com/users/lorentzkim/gists{/gist_id}","starred_url":"https://api.github.com/users/lorentzkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorentzkim/subscriptions","organizations_url":"https://api.github.com/users/lorentzkim/orgs","repos_url":"https://api.github.com/users/lorentzkim/repos","events_url":"https://api.github.com/users/lorentzkim/events{/privacy}","received_events_url":"https://api.github.com/users/lorentzkim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lorentzkim/bittorrent-tracker","description":"Simple, robust, BitTorrent tracker (client & server) implementation","fork":true,"url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker","forks_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/forks","keys_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/teams","hooks_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/hooks","issue_events_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/issues/events{/number}","events_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/events","assignees_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/assignees{/user}","branches_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/branches{/branch}","tags_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/tags","blobs_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/languages","stargazers_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/stargazers","contributors_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/contributors","subscribers_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/subscribers","subscription_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/subscription","commits_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/contents/{+path}","compare_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/merges","archive_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/downloads","issues_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/issues{/number}","pulls_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/labels{/name}","releases_url":"https://api.github.com/repos/lorentzkim/bittorrent-tracker/releases{/id}","created_at":"2015-06-22T18:43:51Z","updated_at":"2015-06-22T18:43:51Z","pushed_at":"2015-07-04T05:09:55Z","git_url":"git://github.com/lorentzkim/bittorrent-tracker.git","ssh_url":"git@github.com:lorentzkim/bittorrent-tracker.git","clone_url":"https://github.com/lorentzkim/bittorrent-tracker.git","svn_url":"https://github.com/lorentzkim/bittorrent-tracker","homepage":"http://webtorrent.io","size":490,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"feross:master","ref":"master","sha":"3abb687b892bf0bd40b8e474e9607cc955f450d3","user":{"login":"feross","id":121766,"avatar_url":"https://avatars.githubusercontent.com/u/121766?v=3","gravatar_id":"","url":"https://api.github.com/users/feross","html_url":"https://github.com/feross","followers_url":"https://api.github.com/users/feross/followers","following_url":"https://api.github.com/users/feross/following{/other_user}","gists_url":"https://api.github.com/users/feross/gists{/gist_id}","starred_url":"https://api.github.com/users/feross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feross/subscriptions","organizations_url":"https://api.github.com/users/feross/orgs","repos_url":"https://api.github.com/users/feross/repos","events_url":"https://api.github.com/users/feross/events{/privacy}","received_events_url":"https://api.github.com/users/feross/received_events","type":"User","site_admin":false},"repo":{"id":18131537,"name":"bittorrent-tracker","full_name":"feross/bittorrent-tracker","owner":{"login":"feross","id":121766,"avatar_url":"https://avatars.githubusercontent.com/u/121766?v=3","gravatar_id":"","url":"https://api.github.com/users/feross","html_url":"https://github.com/feross","followers_url":"https://api.github.com/users/feross/followers","following_url":"https://api.github.com/users/feross/following{/other_user}","gists_url":"https://api.github.com/users/feross/gists{/gist_id}","starred_url":"https://api.github.com/users/feross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feross/subscriptions","organizations_url":"https://api.github.com/users/feross/orgs","repos_url":"https://api.github.com/users/feross/repos","events_url":"https://api.github.com/users/feross/events{/privacy}","received_events_url":"https://api.github.com/users/feross/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/feross/bittorrent-tracker","description":"Simple, robust, BitTorrent tracker (client & server) implementation","fork":false,"url":"https://api.github.com/repos/feross/bittorrent-tracker","forks_url":"https://api.github.com/repos/feross/bittorrent-tracker/forks","keys_url":"https://api.github.com/repos/feross/bittorrent-tracker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/feross/bittorrent-tracker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/feross/bittorrent-tracker/teams","hooks_url":"https://api.github.com/repos/feross/bittorrent-tracker/hooks","issue_events_url":"https://api.github.com/repos/feross/bittorrent-tracker/issues/events{/number}","events_url":"https://api.github.com/repos/feross/bittorrent-tracker/events","assignees_url":"https://api.github.com/repos/feross/bittorrent-tracker/assignees{/user}","branches_url":"https://api.github.com/repos/feross/bittorrent-tracker/branches{/branch}","tags_url":"https://api.github.com/repos/feross/bittorrent-tracker/tags","blobs_url":"https://api.github.com/repos/feross/bittorrent-tracker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/feross/bittorrent-tracker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/feross/bittorrent-tracker/git/refs{/sha}","trees_url":"https://api.github.com/repos/feross/bittorrent-tracker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/feross/bittorrent-tracker/statuses/{sha}","languages_url":"https://api.github.com/repos/feross/bittorrent-tracker/languages","stargazers_url":"https://api.github.com/repos/feross/bittorrent-tracker/stargazers","contributors_url":"https://api.github.com/repos/feross/bittorrent-tracker/contributors","subscribers_url":"https://api.github.com/repos/feross/bittorrent-tracker/subscribers","subscription_url":"https://api.github.com/repos/feross/bittorrent-tracker/subscription","commits_url":"https://api.github.com/repos/feross/bittorrent-tracker/commits{/sha}","git_commits_url":"https://api.github.com/repos/feross/bittorrent-tracker/git/commits{/sha}","comments_url":"https://api.github.com/repos/feross/bittorrent-tracker/comments{/number}","issue_comment_url":"https://api.github.com/repos/feross/bittorrent-tracker/issues/comments{/number}","contents_url":"https://api.github.com/repos/feross/bittorrent-tracker/contents/{+path}","compare_url":"https://api.github.com/repos/feross/bittorrent-tracker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/feross/bittorrent-tracker/merges","archive_url":"https://api.github.com/repos/feross/bittorrent-tracker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/feross/bittorrent-tracker/downloads","issues_url":"https://api.github.com/repos/feross/bittorrent-tracker/issues{/number}","pulls_url":"https://api.github.com/repos/feross/bittorrent-tracker/pulls{/number}","milestones_url":"https://api.github.com/repos/feross/bittorrent-tracker/milestones{/number}","notifications_url":"https://api.github.com/repos/feross/bittorrent-tracker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/feross/bittorrent-tracker/labels{/name}","releases_url":"https://api.github.com/repos/feross/bittorrent-tracker/releases{/id}","created_at":"2014-03-26T08:37:20Z","updated_at":"2015-06-30T21:40:32Z","pushed_at":"2015-07-04T05:09:55Z","git_url":"git://github.com/feross/bittorrent-tracker.git","ssh_url":"git@github.com:feross/bittorrent-tracker.git","clone_url":"https://github.com/feross/bittorrent-tracker.git","svn_url":"https://github.com/feross/bittorrent-tracker","homepage":"http://webtorrent.io","size":1317,"stargazers_count":131,"watchers_count":131,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":7,"forks":40,"open_issues":7,"watchers":131,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82"},"html":{"href":"https://github.com/feross/bittorrent-tracker/pull/82"},"issue":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/issues/82"},"comments":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/issues/82/comments"},"review_comments":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82/comments"},"review_comment":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/pulls/82/commits"},"statuses":{"href":"https://api.github.com/repos/feross/bittorrent-tracker/statuses/18c170ef8786e3c37ac07069c85bdacd8222ff15"}}}}