{"action":"created","comment":{"url":"https://api.github.com/repos/mediachain/aleph/pulls/comments/79889184","id":79889184,"diff_hunk":"@@ -0,0 +1,82 @@\n+const libp2p = require('libp2p-ipfs')\n+const PeerId = require('peer-id')\n+const PeerInfo = require('peer-info')\n+const Multiaddr = require('multiaddr')\n+const b58 = require('bs58')\n+const pb = require('../protobuf')\n+const pull = require('pull-stream')\n+const { protobufStream } = require('./util')\n+const binstring = require('binstring')\n+\n+const DEFAULT_LISTEN_ADDR = Multiaddr('/ip4/127.0.0.1/tcp/9002')\n+\n+class MediachainNode extends libp2p.Node {\n+  directory: PeerInfo\n+\n+  constructor (peerId: PeerId, dirInfo: PeerInfo, listenAddrs: Array<Multiaddr> = [DEFAULT_LISTEN_ADDR]) {\n+    const peerInfo = new PeerInfo(peerId)\n+    listenAddrs.forEach((addr: Multiaddr) => {\n+      peerInfo.multiaddr.add(addr)\n+    })\n+\n+    super(peerInfo)\n+    this.directory = dirInfo\n+  }\n+\n+  lookup (peerId: string): Promise<PeerInfo> {\n+    let mhash: Buffer\n+    try {\n+      mhash = new Buffer(b58.decode(peerId), 'binary')\n+    } catch (err) {\n+      return Promise.reject(err)\n+    }\n+\n+    const req = pb.dir.LookupPeerRequest.encode({\n+      id: binstring(mhash, {in: 'buffer', out: 'binary'})\n+    })\n+\n+    return new Promise((resolve, reject) => {\n+      this.dialByPeerInfo(this.directory, '/mediachain/dir/lookup', (err: ?Error, conn: any) => { // TODO: type for conn","path":"src/peer/node.js","position":null,"original_position":39,"commit_id":"0403c410dfc07761b340c61d06570765e7b43ccf","original_commit_id":"50db30aecb1a175adc141452659f949ea1e4e5f8","user":{"login":"yusefnapora","id":678715,"avatar_url":"https://avatars.githubusercontent.com/u/678715?v=3","gravatar_id":"","url":"https://api.github.com/users/yusefnapora","html_url":"https://github.com/yusefnapora","followers_url":"https://api.github.com/users/yusefnapora/followers","following_url":"https://api.github.com/users/yusefnapora/following{/other_user}","gists_url":"https://api.github.com/users/yusefnapora/gists{/gist_id}","starred_url":"https://api.github.com/users/yusefnapora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yusefnapora/subscriptions","organizations_url":"https://api.github.com/users/yusefnapora/orgs","repos_url":"https://api.github.com/users/yusefnapora/repos","events_url":"https://api.github.com/users/yusefnapora/events{/privacy}","received_events_url":"https://api.github.com/users/yusefnapora/received_events","type":"User","site_admin":false},"body":"yeah, true.  rewriting the libp2p node class is probably worth doing","created_at":"2016-09-21T17:34:09Z","updated_at":"2016-09-21T17:34:09Z","html_url":"https://github.com/mediachain/aleph/pull/13#discussion_r79889184","pull_request_url":"https://api.github.com/repos/mediachain/aleph/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/comments/79889184"},"html":{"href":"https://github.com/mediachain/aleph/pull/13#discussion_r79889184"},"pull_request":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/mediachain/aleph/pulls/13","id":86063968,"html_url":"https://github.com/mediachain/aleph/pull/13","diff_url":"https://github.com/mediachain/aleph/pull/13.diff","patch_url":"https://github.com/mediachain/aleph/pull/13.patch","issue_url":"https://api.github.com/repos/mediachain/aleph/issues/13","number":13,"state":"open","locked":false,"title":"[WIP] p2p","user":{"login":"parkan","id":204986,"avatar_url":"https://avatars.githubusercontent.com/u/204986?v=3","gravatar_id":"","url":"https://api.github.com/users/parkan","html_url":"https://github.com/parkan","followers_url":"https://api.github.com/users/parkan/followers","following_url":"https://api.github.com/users/parkan/following{/other_user}","gists_url":"https://api.github.com/users/parkan/gists{/gist_id}","starred_url":"https://api.github.com/users/parkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkan/subscriptions","organizations_url":"https://api.github.com/users/parkan/orgs","repos_url":"https://api.github.com/users/parkan/repos","events_url":"https://api.github.com/users/parkan/events{/privacy}","received_events_url":"https://api.github.com/users/parkan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-20T21:57:05Z","updated_at":"2016-09-21T17:34:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ec83450ed3acb8f1f1ed3cd6687bbfad08442e0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mediachain/aleph/pulls/13/commits","review_comments_url":"https://api.github.com/repos/mediachain/aleph/pulls/13/comments","review_comment_url":"https://api.github.com/repos/mediachain/aleph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mediachain/aleph/issues/13/comments","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/0403c410dfc07761b340c61d06570765e7b43ccf","head":{"label":"mediachain:yn-p2p","ref":"yn-p2p","sha":"0403c410dfc07761b340c61d06570765e7b43ccf","user":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"repo":{"id":66977529,"name":"aleph","full_name":"mediachain/aleph","owner":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mediachain/aleph","description":"א: The mediachain universe ","fork":false,"url":"https://api.github.com/repos/mediachain/aleph","forks_url":"https://api.github.com/repos/mediachain/aleph/forks","keys_url":"https://api.github.com/repos/mediachain/aleph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mediachain/aleph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mediachain/aleph/teams","hooks_url":"https://api.github.com/repos/mediachain/aleph/hooks","issue_events_url":"https://api.github.com/repos/mediachain/aleph/issues/events{/number}","events_url":"https://api.github.com/repos/mediachain/aleph/events","assignees_url":"https://api.github.com/repos/mediachain/aleph/assignees{/user}","branches_url":"https://api.github.com/repos/mediachain/aleph/branches{/branch}","tags_url":"https://api.github.com/repos/mediachain/aleph/tags","blobs_url":"https://api.github.com/repos/mediachain/aleph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mediachain/aleph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mediachain/aleph/git/refs{/sha}","trees_url":"https://api.github.com/repos/mediachain/aleph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/{sha}","languages_url":"https://api.github.com/repos/mediachain/aleph/languages","stargazers_url":"https://api.github.com/repos/mediachain/aleph/stargazers","contributors_url":"https://api.github.com/repos/mediachain/aleph/contributors","subscribers_url":"https://api.github.com/repos/mediachain/aleph/subscribers","subscription_url":"https://api.github.com/repos/mediachain/aleph/subscription","commits_url":"https://api.github.com/repos/mediachain/aleph/commits{/sha}","git_commits_url":"https://api.github.com/repos/mediachain/aleph/git/commits{/sha}","comments_url":"https://api.github.com/repos/mediachain/aleph/comments{/number}","issue_comment_url":"https://api.github.com/repos/mediachain/aleph/issues/comments{/number}","contents_url":"https://api.github.com/repos/mediachain/aleph/contents/{+path}","compare_url":"https://api.github.com/repos/mediachain/aleph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mediachain/aleph/merges","archive_url":"https://api.github.com/repos/mediachain/aleph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mediachain/aleph/downloads","issues_url":"https://api.github.com/repos/mediachain/aleph/issues{/number}","pulls_url":"https://api.github.com/repos/mediachain/aleph/pulls{/number}","milestones_url":"https://api.github.com/repos/mediachain/aleph/milestones{/number}","notifications_url":"https://api.github.com/repos/mediachain/aleph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mediachain/aleph/labels{/name}","releases_url":"https://api.github.com/repos/mediachain/aleph/releases{/id}","deployments_url":"https://api.github.com/repos/mediachain/aleph/deployments","created_at":"2016-08-30T21:01:45Z","updated_at":"2016-09-20T17:10:25Z","pushed_at":"2016-09-21T16:47:22Z","git_url":"git://github.com/mediachain/aleph.git","ssh_url":"git@github.com:mediachain/aleph.git","clone_url":"https://github.com/mediachain/aleph.git","svn_url":"https://github.com/mediachain/aleph","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"base":{"label":"mediachain:master","ref":"master","sha":"2a647417f77490944e0b03b786f1c1d49eb69c7e","user":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"repo":{"id":66977529,"name":"aleph","full_name":"mediachain/aleph","owner":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mediachain/aleph","description":"א: The mediachain universe ","fork":false,"url":"https://api.github.com/repos/mediachain/aleph","forks_url":"https://api.github.com/repos/mediachain/aleph/forks","keys_url":"https://api.github.com/repos/mediachain/aleph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mediachain/aleph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mediachain/aleph/teams","hooks_url":"https://api.github.com/repos/mediachain/aleph/hooks","issue_events_url":"https://api.github.com/repos/mediachain/aleph/issues/events{/number}","events_url":"https://api.github.com/repos/mediachain/aleph/events","assignees_url":"https://api.github.com/repos/mediachain/aleph/assignees{/user}","branches_url":"https://api.github.com/repos/mediachain/aleph/branches{/branch}","tags_url":"https://api.github.com/repos/mediachain/aleph/tags","blobs_url":"https://api.github.com/repos/mediachain/aleph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mediachain/aleph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mediachain/aleph/git/refs{/sha}","trees_url":"https://api.github.com/repos/mediachain/aleph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/{sha}","languages_url":"https://api.github.com/repos/mediachain/aleph/languages","stargazers_url":"https://api.github.com/repos/mediachain/aleph/stargazers","contributors_url":"https://api.github.com/repos/mediachain/aleph/contributors","subscribers_url":"https://api.github.com/repos/mediachain/aleph/subscribers","subscription_url":"https://api.github.com/repos/mediachain/aleph/subscription","commits_url":"https://api.github.com/repos/mediachain/aleph/commits{/sha}","git_commits_url":"https://api.github.com/repos/mediachain/aleph/git/commits{/sha}","comments_url":"https://api.github.com/repos/mediachain/aleph/comments{/number}","issue_comment_url":"https://api.github.com/repos/mediachain/aleph/issues/comments{/number}","contents_url":"https://api.github.com/repos/mediachain/aleph/contents/{+path}","compare_url":"https://api.github.com/repos/mediachain/aleph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mediachain/aleph/merges","archive_url":"https://api.github.com/repos/mediachain/aleph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mediachain/aleph/downloads","issues_url":"https://api.github.com/repos/mediachain/aleph/issues{/number}","pulls_url":"https://api.github.com/repos/mediachain/aleph/pulls{/number}","milestones_url":"https://api.github.com/repos/mediachain/aleph/milestones{/number}","notifications_url":"https://api.github.com/repos/mediachain/aleph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mediachain/aleph/labels{/name}","releases_url":"https://api.github.com/repos/mediachain/aleph/releases{/id}","deployments_url":"https://api.github.com/repos/mediachain/aleph/deployments","created_at":"2016-08-30T21:01:45Z","updated_at":"2016-09-20T17:10:25Z","pushed_at":"2016-09-21T16:47:22Z","git_url":"git://github.com/mediachain/aleph.git","ssh_url":"git@github.com:mediachain/aleph.git","clone_url":"https://github.com/mediachain/aleph.git","svn_url":"https://github.com/mediachain/aleph","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/13"},"html":{"href":"https://github.com/mediachain/aleph/pull/13"},"issue":{"href":"https://api.github.com/repos/mediachain/aleph/issues/13"},"comments":{"href":"https://api.github.com/repos/mediachain/aleph/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/mediachain/aleph/statuses/0403c410dfc07761b340c61d06570765e7b43ccf"}}}}
{"actor":{"display_login":"yusefnapora"}}