Skip to content

Commit 07c130b

Browse files
committed
chore: add missing dep
1 parent 3619aca commit 07c130b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@libp2p/interfaces": "^1.3.23",
4747
"@libp2p/logger": "^1.1.4",
4848
"@libp2p/peer-id": "^1.1.10",
49+
"@libp2p/topology": "^1.1.7",
4950
"denque": "^1.5.0",
5051
"err-code": "^3.0.1",
5152
"iso-random-stream": "^2.0.2",

ts/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,8 +1856,9 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
18561856
}
18571857

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

1860-
if (tosend.size === 0 && !this.opts.allowPublishToZeroPeers) {
1861+
if (tosend.size === 0 && !this.opts.allowPublishToZeroPeers && !willSendToSelf) {
18611862
throw Error('PublishError.InsufficientPeers')
18621863
}
18631864

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

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

18851886
super.dispatchEvent(

0 commit comments

Comments
 (0)