Skip to content

Commit

Permalink
feat(brave): use TCP Bootstrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 11, 2019
1 parent 79ebbee commit 0d28d66
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
22 changes: 18 additions & 4 deletions add-on/src/lib/ipfs-client/embedded-chromesockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const maToUri = require('multiaddr-to-uri')
const getPort = require('get-port')

// libp2p
// const WS = require('libp2p-websockets')
const WS = require('libp2p-websockets')
// const WSM = require('libp2p-websocket-star-multi')
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
Expand All @@ -42,9 +42,19 @@ async function buildConfig (opts) {

const ipfsNodeConfig = mergeOptions.call({ concatArrays: true }, defaultOpts, userOpts, { start: false })

// TODO: replace object with function that builds the bundle
// See defaultBundle in js-ipfs/src/core/components/libp2p.js
ipfsNodeConfig.libp2p = {
// node defaults instead of browser ones
switch: {
blacklistTTL: 2 * 60 * 1e3, // 2 minute base
blackListAttempts: 5, // back off 5 times
maxParallelDials: 150,
maxColdCalls: 50,
dialTimeout: 10e3 // Be strict with dial time
},
modules: {
transport: [new TCP()],
transport: [new TCP(), new WS()],
peerDiscovery: [
MulticastDNS,
new Bootstrap({ list: ipfsNodeConfig.config.Bootstrap })
Expand All @@ -64,8 +74,12 @@ async function buildConfig (opts) {
}
},
dht: {
// TODO: check if below is needed after js-ipfs is released with DHT disabled
enabled: false
// TODO: KadDHT seems to be CPU-bound in browser context, needs investigation
kBucketSize: 20,
enabled: false,
randomWalk: {
enabled: false
}
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions add-on/src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function buildDefaultIpfsNodeConfig () {
Swarm: []
},
Bootstrap: [
// TCP Bootstrappers from https://github.com/ipfs/js-ipfs/blob/v0.37.1/src/core/runtime/config-nodejs.js#L22
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
Expand All @@ -68,14 +69,23 @@ function buildDefaultIpfsNodeConfig () {
'/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
// connect to preload nodes, but over tcp :)
// Twist: connect to preload nodes, but over tcp :)
'/dns4/node0.preload.ipfs.io/tcp/4001/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/node1.preload.ipfs.io/tcp/4001/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
'/dns4/node1.preload.ipfs.io/tcp/4001/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6',
// WebSockets versions from https://github.com/ipfs/js-ipfs/blob/v0.37.1/src/core/runtime/config-browser.js#L20
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
'/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
],
Swarm: {
ConnMgr: {
LowWater: 100,
HighWater: 200
HighWater: 250
}
}
}
Expand Down

0 comments on commit 0d28d66

Please sign in to comment.