From f82a689e0faeb594a9d3f479e22212f60e2ec16d Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 26 Nov 2022 18:09:20 -0500 Subject: [PATCH] *Bug fix channel opening --- src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1463c2a..7bbe5dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -92,7 +92,7 @@ export default class DHTFlood extends EventEmitter { const self = this; - if (!mux.opened({ protocol: PROTOCOL })) { + if (!mux.opened({ protocol: this.protocol })) { chan = mux.createChannel({ protocol: this.protocol, async onopen() { @@ -102,7 +102,9 @@ export default class DHTFlood extends EventEmitter { self.emit("peer-remove", peer); }, }); - peer[FLOOD_SYMBOL] = chan; + if (chan) { + peer[FLOOD_SYMBOL] = chan; + } } chan = peer[FLOOD_SYMBOL];