From d2ef6b5447f1f53c80cbf97ce2678f68f484aab2 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Mon, 5 Feb 2018 13:40:44 +0100 Subject: [PATCH] feat: add DI --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index 907eb86e63..d1b964d6de 100644 --- a/src/index.js +++ b/src/index.js @@ -169,6 +169,11 @@ class Node extends EventEmitter { if (transport.filter(multiaddrs).length > 0) { this.swarm.transport.add( transport.tag || transport.constructor.name, transport) + if (typeof transport._setSwarm === 'function') transport._setSwarm(this) + if (typeof transport.discovery === 'object' && typeof transport.discovery.start === 'function') { + if (!this.modules.discovery) this.modules.discovery = [] + this.modules.discovery.push(transport.discovery) + } } else if (transport.constructor && transport.constructor.name === 'WebSockets') { // TODO find a cleaner way to signal that a transport is always