Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: add DHT in browser too, enable and pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 26, 2017
1 parent 4880be2 commit df424e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
"detect-node": "^2.0.3",
"dir-compare": "^1.4.0",
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.2.1",
"eslint-plugin-react": "^7.3.0",
"execa": "^0.8.0",
"expose-loader": "^0.7.3",
"form-data": "^2.2.0",
"form-data": "^2.3.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.30.1",
"ipfsd-ctl": "~0.21.0",
Expand All @@ -93,14 +93,14 @@
"bl": "^1.2.1",
"boom": "^5.2.0",
"cids": "^0.5.1",
"debug": "^3.0.0",
"debug": "^3.0.1",
"fsm-event": "^2.1.0",
"glob": "^7.1.2",
"hapi": "^16.5.2",
"hapi-set-header": "^1.0.2",
"hoek": "^4.2.0",
"ipfs-api": "^14.1.2",
"ipfs-bitswap": "~0.15.0",
"ipfs-bitswap": "~0.16.0",
"ipfs-block": "~0.6.0",
"ipfs-block-service": "~0.12.0",
"ipfs-multipart": "~0.1.0",
Expand All @@ -118,7 +118,7 @@
"libp2p-multiplex": "^0.4.4",
"libp2p-railing": "^0.6.1",
"libp2p-secio": "^0.7.1",
"libp2p-swarm": "^0.31.0",
"libp2p-swarm": "^0.31.2",
"libp2p-tcp": "^0.10.2",
"libp2p-webrtc-star": "^0.12.0",
"libp2p-websockets": "^0.10.1",
Expand All @@ -129,7 +129,7 @@
"mafmt": "^2.1.8",
"mkdirp": "^0.5.1",
"multiaddr": "^2.3.0",
"multihashes": "~0.4.5",
"multihashes": "~0.4.8",
"once": "^1.4.0",
"path-exists": "^3.0.0",
"peer-book": "^0.5.0",
Expand Down
11 changes: 8 additions & 3 deletions src/core/runtime/libp2p-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ const WebRTCStar = require('libp2p-webrtc-star')
const Multiplex = require('libp2p-multiplex')
const SECIO = require('libp2p-secio')
const Railing = require('libp2p-railing')
const KadDHT = require('libp2p-kad-dht')
const libp2p = require('libp2p')

class Node extends libp2p {
constructor (peerInfo, peerBook, options) {
options = options || {}
const wstar = new WebRTCStar()
const wStar = new WebRTCStar()

const modules = {
transport: [new WS(), wstar],
transport: [new WS(), wStar],
connection: {
muxer: [Multiplex],
crypto: [SECIO]
},
discovery: [wstar.discovery]
discovery: [wStar.discovery]
}

if (options.dht) {
modules.DHT = KadDHT
}

if (options.bootstrap) {
Expand Down

0 comments on commit df424e5

Please sign in to comment.