Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(brave): delegated peers and content routing #739

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions add-on/src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.optionDefaults = Object.freeze({
ipfsApiUrl: buildIpfsApiUrl(),
ipfsApiPollMs: 3000,
ipfsProxy: true, // window.ipfs
logNamespaces: 'jsipfs*,ipfs*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
logNamespaces: 'jsipfs*,ipfs*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
})

function buildCustomGatewayUrl () {
Expand Down Expand Up @@ -60,17 +60,26 @@ function buildDefaultIpfsNodeConfig () {
config.config.Addresses.Gateway = '/ip4/127.0.0.1/tcp/9091'

// Until we have MulticastDNS+DNS, peer discovery is done over ws-star
config.config.Addresses.Swarm = ['/dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star']
config.config.Addresses.Swarm = [
'/dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star',
'/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star'
]
// Until DHT and p2p transport are ready, delegate + preload
// Note: we use .preload.ipfs.io and .delegate.ipfs.io as means of http sharding (12 instead of 6 concurrent requests)
const delegates = [
'/dns4/node0.preload.ipfs.io/tcp/443/https',
'/dns4/node1.preload.ipfs.io/tcp/443/https'
'/dns4/node1.delegate.ipfs.io/tcp/443/https',
Copy link
Member Author

@lidel lidel Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got dedicated hostnames for use in delegate contexts: ipfs/js-ipfs#2291

'/dns4/node0.delegate.ipfs.io/tcp/443/https'
]
// Delegated Content and Peer Routing: https://github.com/ipfs/js-ipfs/pull/2195
// TODO: delegated routing blocked by https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/12
// config.config.Addresses.Delegates = delegates
// TODO: are preloads needed? should Brave have own nodes?
config.preload = { enabled: true, addresses: delegates }
config.config.Addresses.Delegates = delegates
// TODO: when we have p2p transport, are preloads still needed? should Brave have own nodes?
config.preload = {
enabled: true,
addresses: [
'/dns4/node1.preload.ipfs.io/tcp/443/https',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will reuse delegates here, but for now I use .preload. hostnames to make it easier to see which requests are from libp2p's routing modules, and which ones are triggered by preload logic in js-ipfs.

'/dns4/node0.preload.ipfs.io/tcp/443/https'
]
}
/*
(Sidenote on why we need API for Web UI)
Gateway can run without API port,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"private": true,
"preferGlobal": false,
"resolutions": {
"libp2p-delegated-content-routing": "0.2.4",
"libp2p-delegated-peer-routing": "0.2.4",
"@hapi/hapi": "https://github.com/lidel/hapi/tarball/ccbf84ba5edc9b24564fdd166e3ee6d81c4c02d8/hapi.tar.gz",
"pino": "5.12.3",
"hapi-pino": "https://github.com/pinojs/hapi-pino/tarball/3767ed6b67601831e176e084ed82ba4ed9f726e6/hapi-pino.tar.gz",
Expand Down Expand Up @@ -124,7 +126,7 @@
"get-port": "5.0.0",
"http-dns": "3.0.1",
"http-node": "1.2.0",
"ipfs": "https://github.com/ipfs/js-ipfs/tarball/2ae6b672c222555b1a068141f2acfe4b5f39b709/js-ipfs.tar.gz",
"ipfs": "https://github.com/ipfs/js-ipfs/tarball/6fa8f88310a4f7f451f0f6846e435134376703e6/js-ipfs.tar.gz",
"ipfs-css": "0.12.0",
"ipfs-http-client": "33.1.0",
"ipfs-http-response": "0.3.1",
Expand Down
Loading