Skip to content

Commit 1b2af2c

Browse files
authored
fix: incoming stream conn (#30)
1 parent 39309a5 commit 1b2af2c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ class PubsubBaseProtocol extends EventEmitter {
146146
* @param {Object} props
147147
* @param {string} props.protocol
148148
* @param {DuplexStream} props.strean
149-
* @param {PeerId} props.remotePeer remote peer-id
149+
* @param {Connection} props.connection connection
150150
*/
151-
async _onIncomingStream ({ protocol, stream, remotePeer }) {
152-
const peerInfo = await PeerInfo.create(remotePeer)
151+
async _onIncomingStream ({ protocol, stream, connection }) {
152+
const peerInfo = await PeerInfo.create(connection.remotePeer)
153153
peerInfo.protocols.add(protocol)
154154

155155
const idB58Str = peerInfo.id.toB58String()

test/pubsub.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ describe('pubsub base protocol', () => {
180180
await handlerB({
181181
protocol,
182182
stream: c1.stream,
183-
remotePeer: peerInfoA.id
183+
connection: {
184+
remotePeer: peerInfoA.id
185+
}
184186
})
185187

186188
expect(pubsubA.peers.size).to.be.eql(1)
@@ -200,7 +202,9 @@ describe('pubsub base protocol', () => {
200202
await handlerB({
201203
protocol,
202204
stream: c1.stream,
203-
remotePeer: peerInfoA.id
205+
connection: {
206+
remotePeer: peerInfoA.id
207+
}
204208
})
205209

206210
// Notice peers of disconnect

0 commit comments

Comments
 (0)