diff --git a/src/index.ts b/src/index.ts index fc89ff7a..4be272c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -844,7 +844,7 @@ export class GossipSub extends TypedEventEmitter implements Pub // TODO make this behavior more robust // This behavior is different than for inbound streams // If an outbound stream already exists, don't create a new stream - if (this.streamsOutbound.has(id)) { + if (this.streamsOutbound.get(id)?.rawStream?.status === "open") { return } @@ -1834,7 +1834,7 @@ export class GossipSub extends TypedEventEmitter implements Pub private async directConnect (): Promise { const toconnect: string[] = [] this.direct.forEach((id) => { - if (!this.streamsOutbound.has(id)) { + if (!this.streamsOutbound.get(id)?.rawStream?.status === "open") { toconnect.push(id) } })