mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
chore: update delegates config docs to use http client (#853)
This commit is contained in:
parent
46cb46188a
commit
9941414a91
@ -391,6 +391,7 @@ const Libp2p = require('libp2p')
|
|||||||
const TCP = require('libp2p-tcp')
|
const TCP = require('libp2p-tcp')
|
||||||
const MPLEX = require('libp2p-mplex')
|
const MPLEX = require('libp2p-mplex')
|
||||||
const { NOISE } = require('libp2p-noise')
|
const { NOISE } = require('libp2p-noise')
|
||||||
|
const ipfsHttpClient = require('ipfs-http-client')
|
||||||
const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
|
const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
|
||||||
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
|
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
|
||||||
const PeerId = require('peer-id')
|
const PeerId = require('peer-id')
|
||||||
@ -398,17 +399,25 @@ const PeerId = require('peer-id')
|
|||||||
// create a peerId
|
// create a peerId
|
||||||
const peerId = await PeerId.create()
|
const peerId = await PeerId.create()
|
||||||
|
|
||||||
|
const delegatedPeerRouting = new DelegatedPeerRouter(ipfsHttpClient({
|
||||||
|
host: 'node0.delegate.ipfs.io' // In production you should setup your own delegates
|
||||||
|
protocol: 'https',
|
||||||
|
port: 443
|
||||||
|
}))
|
||||||
|
|
||||||
|
const delegatedContentRouting = new DelegatedContentRouter(peerId, ipfsHttpClient({
|
||||||
|
host: 'node0.delegate.ipfs.io' // In production you should setup your own delegates
|
||||||
|
protocol: 'https',
|
||||||
|
port: 443
|
||||||
|
}))
|
||||||
|
|
||||||
const node = await Libp2p.create({
|
const node = await Libp2p.create({
|
||||||
modules: {
|
modules: {
|
||||||
transport: [TCP],
|
transport: [TCP],
|
||||||
streamMuxer: [MPLEX],
|
streamMuxer: [MPLEX],
|
||||||
connEncryption: [NOISE],
|
connEncryption: [NOISE],
|
||||||
contentRouting: [
|
contentRouting: [delegatedContentRouting],
|
||||||
new DelegatedContentRouter(peerId)
|
peerRouting: [delegatedPeerRouting],
|
||||||
],
|
|
||||||
peerRouting: [
|
|
||||||
new DelegatedPeerRouter()
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
peerId,
|
peerId,
|
||||||
peerRouting: { // Peer routing configuration
|
peerRouting: { // Peer routing configuration
|
||||||
|
@ -107,9 +107,7 @@ describe('content-routing', () => {
|
|||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
port: 60197
|
port: 60197
|
||||||
}), [
|
}))
|
||||||
multiaddr('/ip4/0.0.0.0/tcp/60197')
|
|
||||||
])
|
|
||||||
|
|
||||||
;[node] = await peerUtils.createPeer({
|
;[node] = await peerUtils.createPeer({
|
||||||
config: mergeOptions(baseOptions, {
|
config: mergeOptions(baseOptions, {
|
||||||
@ -253,9 +251,7 @@ describe('content-routing', () => {
|
|||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
port: 60197
|
port: 60197
|
||||||
}), [
|
}))
|
||||||
multiaddr('/ip4/0.0.0.0/tcp/60197')
|
|
||||||
])
|
|
||||||
|
|
||||||
;[node] = await peerUtils.createPeer({
|
;[node] = await peerUtils.createPeer({
|
||||||
config: mergeOptions(routingOptions, {
|
config: mergeOptions(routingOptions, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user