Skip to content

Commit

Permalink
chore: update interface dependencies
Browse files Browse the repository at this point in the history
BREAKING CHANGE: connection interface updated
  • Loading branch information
wemeetagain committed Jun 29, 2022
1 parent 475c861 commit 8397217
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@
},
"homepage": "https://github.com/ChainSafe/js-libp2p-gossipsub#readme",
"dependencies": {
"@libp2p/components": "^1.0.0",
"@libp2p/components": "^2.0.0",
"@libp2p/crypto": "^1.0.0",
"@libp2p/interface-connection": "^2.0.0",
"@libp2p/interface-keys": "^1.0.2",
"@libp2p/interface-peer-id": "^1.0.2",
"@libp2p/interface-pubsub": "^1.0.1",
"@libp2p/interface-registrar": "^1.0.0",
"@libp2p/interface-registrar": "^2.0.0",
"@libp2p/interfaces": "^3.0.2",
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.13",
"@libp2p/peer-record": "^2.0.0",
"@libp2p/pubsub": "^2.0.0",
"@libp2p/topology": "^2.0.0",
"@libp2p/pubsub": "^3.0.0",
"@libp2p/topology": "^3.0.0",
"denque": "^1.5.0",
"err-code": "^3.0.1",
"iso-random-stream": "^2.0.2",
Expand All @@ -88,11 +89,11 @@
"devDependencies": {
"@chainsafe/as-sha256": "^0.2.4",
"@dapplion/benchmark": "^0.2.2",
"@libp2p/floodsub": "^2.0.0",
"@libp2p/interface-mocks": "^1.0.1",
"@libp2p/interface-pubsub-compliance-tests": "^1.0.1",
"@libp2p/floodsub": "^3.0.0",
"@libp2p/interface-mocks": "^3.0.1",
"@libp2p/interface-pubsub-compliance-tests": "^1.0.4",
"@libp2p/peer-id-factory": "^1.0.13",
"@libp2p/peer-store": "^2.0.0",
"@libp2p/peer-store": "^3.0.0",
"@multiformats/multiaddr": "^10.2.0",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^3.0.2",
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,14 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
/**
* On an inbound stream opened
*/
private onIncomingStream({ protocol, stream, connection }: IncomingStreamData) {
private onIncomingStream({ stream, connection }: IncomingStreamData) {
if (!this.isStarted()) {
return
}

const peerId = connection.remotePeer
const peer = this.addPeer(peerId, protocol, connection.stat.direction)
// TODO remove this non-nullish assertion after https://github.com/libp2p/js-libp2p-interfaces/pull/265 is incorporated
const peer = this.addPeer(peerId, stream.stat.protocol!, stream.stat.direction)
const inboundStream = peer.attachInboundStream(stream)

this.pipePeerReadStream(peerId, inboundStream).catch((err) => this.log(err))
Expand All @@ -622,8 +623,9 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali

Promise.resolve().then(async () => {
try {
const { stream, protocol } = await conn.newStream(this.multicodecs)
const peer = this.addPeer(peerId, protocol, conn.stat.direction)
const stream = await conn.newStream(this.multicodecs)
// TODO remove this non-nullish assertion after https://github.com/libp2p/js-libp2p-interfaces/pull/265 is incorporated
const peer = this.addPeer(peerId, stream.stat.protocol!, conn.stat.direction)
await peer.attachOutboundStream(stream)
} catch (err) {
this.log(err)
Expand Down

0 comments on commit 8397217

Please sign in to comment.