Skip to content

Commit

Permalink
chore: add missing dep
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Apr 28, 2022
1 parent 3619aca commit 07c130b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@libp2p/interfaces": "^1.3.23",
"@libp2p/logger": "^1.1.4",
"@libp2p/peer-id": "^1.1.10",
"@libp2p/topology": "^1.1.7",
"denque": "^1.5.0",
"err-code": "^3.0.1",
"iso-random-stream": "^2.0.2",
Expand Down
5 changes: 3 additions & 2 deletions ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,9 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
}

const { tosend, tosendCount } = this.selectPeersToPublish(rawMsg.topic)
const willSendToSelf = this.opts.emitSelf === true && this.subscriptions.has(topic)

if (tosend.size === 0 && !this.opts.allowPublishToZeroPeers) {
if (tosend.size === 0 && !this.opts.allowPublishToZeroPeers && !willSendToSelf) {
throw Error('PublishError.InsufficientPeers')
}

Expand All @@ -1879,7 +1880,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
this.metrics?.onPublishMsg(topic, tosendCount, tosend.size, rawMsg.data != null ? rawMsg.data.length : 0)

// Dispatch the message to the user if we are subscribed to the topic
if (this.opts.emitSelf === true && this.subscriptions.has(topic)) {
if (willSendToSelf) {
tosend.add(this.components.getPeerId().toString())

super.dispatchEvent(
Expand Down

0 comments on commit 07c130b

Please sign in to comment.