From 07c130b4f074c026ef93d7ab1c24e4f6725498f7 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 28 Apr 2022 08:06:18 +0100 Subject: [PATCH] chore: add missing dep --- package.json | 1 + ts/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3a7b872e..6584bb7d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/ts/index.ts b/ts/index.ts index d47b5a7c..354d47a1 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1856,8 +1856,9 @@ export class GossipSub extends EventEmitter 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') } @@ -1879,7 +1880,7 @@ export class GossipSub extends EventEmitter 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(