Skip to content

Commit e6f5a82

Browse files
committed
fix peer id
1 parent ad34988 commit e6f5a82

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

example.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,33 @@ p1.on('handshake', function () {
1818
console.log('got handshake, remote peer:', p1.remoteId)
1919
})
2020

21-
p1.on('channel', function (key, channel) {
21+
p1.on('channel', function (channel) {
2222
channel.on('ping', function () {
2323
console.log('got ping')
2424
channel.close()
2525
})
26+
2627
channel.on('close', function () {
2728
console.log('closing shop')
2829
})
29-
channel.on('request', function (block) {
30-
console.log('remote requests:', block)
31-
channel.response(block, Buffer('hello'))
30+
31+
channel.on('request', function (message) {
32+
console.log('remote requests:', message.block)
33+
channel.response({block: message.block, data: Buffer('hello')})
3234
})
3335
})
3436

35-
p2.on('channel', function (key, channel) {
37+
p2.on('channel', function (channel) {
3638
channel.on('close', function () {
3739
console.log('closing')
3840
})
39-
channel.request(1)
40-
channel.request(2)
41+
42+
channel.request({block: 1})
43+
channel.request({block: 2})
4144
channel.ping()
42-
channel.on('response', function (block, data, proof) {
43-
console.log('got response:', block, data, proof)
45+
46+
channel.on('response', function (message) {
47+
console.log('got response:', message)
4448
})
4549
})
4650

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function use (extensions) {
161161

162162
if (!this._protocol.remoteId) {
163163
this.handshake({
164-
peer: this._protocol.id,
164+
peerId: this._protocol.id,
165165
extensions: extensions
166166
})
167167
}

0 commit comments

Comments
 (0)